+2007-04-17 Jeffrey Stedfast <fejj@novell.com>
+
+ * TermInfoDriver.cs (Init): SetEcho(false), we'll be manually
+ echoing from now on (ReadLine() has already been doing this, might
+ as well make ReadKey() behave the same).
+ (GetCursorPosition): No longer need to disable/re-enable echo
+ anymore since it is now always false.
+ (ReadKey): Manually echo the key back to the console just like
+ ReadLine() has been doing (in the interest of consistancy) if
+ intercept is false.
+ (ReadLine): No longer need to disable/re-enable echo, echo is
+ always off now. Also, fixed what appears to have been a typo.
+
2007-04-17 Jeffrey Stedfast <fejj@novell.com>
* TermInfoDriver.cs (IsSpecialKey): Oops, Enter should not be
public TermInfoDriver (string term)
{
#if DEBUG
- File.Delete ("console.log");
+ //File.Delete ("console.log");
logger = new StreamWriter (File.OpenWrite ("console.log"));
#endif
this.term = term;
throw new IOException ("Not a tty.");
inited = true;
+
+ ConsoleDriver.SetEcho (false);
+
string endString = null;
keypadXmit = reader.Get (TermInfoStrings.KeypadXmit);
keypadLocal = reader.Get (TermInfoStrings.KeypadLocal);
void GetCursorPosition ()
{
int row = 0, col = 0;
-
- ConsoleDriver.SetEcho (false);
-
- try {
- WriteConsole ("\x1b[6n");
- if (ConsoleDriver.InternalKeyAvailable (1000) <= 0) {
- noGetPosition = true;
- return;
- }
- int b = stdin.ReadByte ();
- while (b != '\x1b') {
- AddToBuffer (b);
- if (ConsoleDriver.InternalKeyAvailable (100) <= 0)
- return;
- b = stdin.ReadByte ();
- }
+ WriteConsole ("\x1b[6n");
+ if (ConsoleDriver.InternalKeyAvailable (1000) <= 0) {
+ noGetPosition = true;
+ return;
+ }
- b = stdin.ReadByte ();
- if (b != '[') {
- AddToBuffer ('\x1b');
- AddToBuffer (b);
+ int b = stdin.ReadByte ();
+ while (b != '\x1b') {
+ AddToBuffer (b);
+ if (ConsoleDriver.InternalKeyAvailable (100) <= 0)
return;
- }
+ b = stdin.ReadByte ();
+ }
+
+ b = stdin.ReadByte ();
+ if (b != '[') {
+ AddToBuffer ('\x1b');
+ AddToBuffer (b);
+ return;
+ }
+ b = stdin.ReadByte ();
+ if (b != ';') {
+ row = b - '0';
b = stdin.ReadByte ();
- if (b != ';') {
- row = b - '0';
+ while ((b >= '0') && (b <= '9')) {
+ row = row * 10 + b - '0';
b = stdin.ReadByte ();
- while ((b >= '0') && (b <= '9')) {
- row = row * 10 + b - '0';
- b = stdin.ReadByte ();
- }
- // Row/col is 0 based
- row --;
}
+ // Row/col is 0 based
+ row --;
+ }
+ b = stdin.ReadByte ();
+ if (b != 'R') {
+ col = b - '0';
b = stdin.ReadByte ();
- if (b != 'R') {
- col = b - '0';
+ while ((b >= '0') && (b <= '9')) {
+ col = col * 10 + b - '0';
b = stdin.ReadByte ();
- while ((b >= '0') && (b <= '9')) {
- col = col * 10 + b - '0';
- b = stdin.ReadByte ();
- }
- // Row/col is 0 based
- col --;
}
- } finally {
- ConsoleDriver.SetEcho (true);
+ // Row/col is 0 based
+ col --;
}
+#if DEBUG
+ logger.WriteLine ("GetCursorPosition: {0}, {1}", col, row);
+ logger.Flush ();
+#endif
+
cursorLeft = col;
cursorTop = row;
}
if (!inited)
Init ();
- if (intercept)
- ConsoleDriver.SetEcho (false);
-
ConsoleKeyInfo key = ReadKeyInternal ();
- if (intercept)
- ConsoleDriver.SetEcho (true);
+ if (!intercept) {
+ // echo the key back to the console
+ CStreamWriter writer = Console.stdout as CStreamWriter;
+
+ if (writer != null)
+ writer.WriteKey (key);
+ else
+ Console.stdout.Write (key.KeyChar);
+ }
return key;
}
if (!inited)
Init ();
- ConsoleDriver.SetEcho (false);
-
StringBuilder builder = new StringBuilder ();
bool exit = false;
CStreamWriter writer = Console.stdout as CStreamWriter;
rl_startx = cursorLeft;
- rl_starty = cursorLeft;
+ rl_starty = cursorTop;
do {
ConsoleKeyInfo key = ReadKeyInternal ();
char c = key.KeyChar;
Console.stdout.Write (c);
} while (!exit);
- ConsoleDriver.SetEcho (true);
-
rl_startx = -1;
rl_starty = -1;
return builder.ToString ();