private static void Repaint(bool step, bool moveToEnd)
{
int posn = Readline.posn;
int column = Readline.column;
int width;
// Paint the characters in the line.
while (posn < length) {
if (buffer[posn] == '\t') {
width = 8 - (column % 8);
widths[posn] = (byte)width;
while (width > 0) {
Console.Write(' ');
--width;
++column;
}
} else if (buffer[posn] < 0x20) {
Console.Write('^');
Console.Write((char)(buffer[posn] + 0x40));
widths[posn] = 2;
column += 2;
} else if (buffer[posn] == '\u007F') {
Console.Write('^');
Console.Write('?');
widths[posn] = 2;
column += 2;
} else {
Console.Write(buffer[posn]);
widths[posn] = 1;
++column;
}
++posn;
}
// Adjust the position of the last column.
if (column > lastColumn) {
lastColumn = column;
} else if (column < lastColumn) {
// We need to clear some characters beyond this point.
width = lastColumn - column;
lastColumn = column;
while (width > 0) {
Console.Write(' ');
--width;
++column;
}
}
// Backspace to the initial cursor position.
if (moveToEnd) {
width = column - lastColumn;
Readline.posn = length;
} else if (step) {
width = column - (Readline.column + widths[Readline.posn]);
Readline.column += widths[Readline.posn];
++(Readline.posn);
} else {
width = column - Readline.column;
}
while (width > 0) {
Console.Write('\u0008');
--width;
}
}