+2006-02-11 Zoltan Varga <vargaz@gmail.com>
+
+ * TermInfoDriver.cs (GetWindowDimensions): Obtain the exact terminal
+ size using an icall.
+ (GetCursorPosition): Convert the row and column to 0 based indexing.
+ Also fix reading of large values.
+ (CreateKeyInfoFromInt): Convert LF to ConsoleKey.Enter.
+
+ * ConsoleDriver.cs (GetTtySize): New icall.
+
2006-02-10 Zoltan Varga <vargaz@gmail.com>
* Array.cs: Fix some methods which previously returned Nullable<T>.
if (b != ';') {
row = b - '0';
b = stdin.ReadByte ();
- if (b != ';')
+ while ((b >= '0') && (b <= '9')) {
row = row * 10 + b - '0';
+ b = stdin.ReadByte ();
+ }
+ // Row/col is 0 based
+ row --;
}
b = stdin.ReadByte ();
if (b != 'R') {
col = b - '0';
b = stdin.ReadByte ();
- if (b != 'R') {
+ while ((b >= '0') && (b <= '9')) {
col = col * 10 + b - '0';
- stdin.ReadByte (); // This should be the 'R'
+ b = stdin.ReadByte ();
}
+ // Row/col is 0 based
+ col --;
}
} finally {
Echo = prevEcho;
void GetWindowDimensions ()
{
//TODO: Handle SIGWINCH
- windowWidth = reader.Get (TermInfoNumbers.Columns);
- string env = Environment.GetEnvironmentVariable ("COLUMNS");
- if (env != null) {
- try {
- windowWidth = (int) UInt32.Parse (env);
- } catch {
+
+ /* Try the ioctl first */
+ if (!ConsoleDriver.GetTtySize (MonoIO.ConsoleOutput, out windowWidth, out windowHeight)) {
+ windowWidth = reader.Get (TermInfoNumbers.Columns);
+ string env = Environment.GetEnvironmentVariable ("COLUMNS");
+ if (env != null) {
+ try {
+ windowWidth = (int) UInt32.Parse (env);
+ } catch {
+ }
}
- }
- windowHeight = reader.Get (TermInfoNumbers.Lines);
- env = Environment.GetEnvironmentVariable ("LINES");
- if (env != null) {
- try {
- windowHeight = (int) UInt32.Parse (env);
- } catch {
+ windowHeight = reader.Get (TermInfoNumbers.Lines);
+ env = Environment.GetEnvironmentVariable ("LINES");
+ if (env != null) {
+ try {
+ windowHeight = (int) UInt32.Parse (env);
+ } catch {
+ }
}
}
bool shift = false;
bool ctrl = false;
bool alt = false;
- // For Ctrl-a to Ctrl-z. Exception: those values in ConsoleKey
- if (n >= 1 && n <= 26 && !(n == 8 || n == 9 || n == 12 || n == 13 || n == 19)) {
+
+ if (n == 10) {
+ key = ConsoleKey.Enter;
+ } else if (n >= 1 && n <= 26 && !(n == 8 || n == 9 || n == 12 || n == 13 || n == 19)) {
+ // For Ctrl-a to Ctrl-z. Exception: those values in ConsoleKey
ctrl = true;
key = ConsoleKey.A + n - 1;
} else if (n == 27) {