2006-02-11 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Sat, 11 Feb 2006 20:22:25 +0000 (20:22 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sat, 11 Feb 2006 20:22:25 +0000 (20:22 -0000)
* console-io.c (ves_icall_System_ConsoleDriver_GetTtySize): New icall
to obtain the terminal size using an ioctl.

svn path=/trunk/mono/; revision=56807

mono/metadata/ChangeLog
mono/metadata/console-io.c
mono/metadata/console-io.h
mono/metadata/icall.c

index 210ea0f97bb573faec2c15246afec8c124c35103..f78bb57be23111824a0060ded4e63186c5b54229 100644 (file)
@@ -1,5 +1,8 @@
 2006-02-11  Zoltan Varga  <vargaz@gmail.com>
 
+       * console-io.c (ves_icall_System_ConsoleDriver_GetTtySize): New icall
+       to obtain the terminal size using an ioctl.
+
        * object.c (mono_nullable_init): Revert this as nullable reference
        types are not valid.
        (mono_nullable_box): Ditto.
index 4d870613688bc5d55c0fb63030be0839a8d380ba..0e491d6dfaf8edb6580091240be976f2609ca7f3 100644 (file)
@@ -76,6 +76,12 @@ ves_icall_System_ConsoleDriver_TtySetup (MonoString *teardown)
        return FALSE;
 }
 
+MonoBoolean
+ves_icall_System_ConsoleDriver_GetTtySize (HANDLE handle, gint32 *width, gint32 *height)
+{
+       return FALSE;
+}
+
 #else
 static struct termios initial_attr;
 
@@ -210,5 +216,26 @@ ves_icall_System_ConsoleDriver_TtySetup (MonoString *teardown)
 
        return TRUE;
 }
+
+MonoBoolean
+ves_icall_System_ConsoleDriver_GetTtySize (HANDLE handle, gint32 *width, gint32 *height)
+{
+#ifdef TIOCGWINSZ
+       struct winsize ws;
+       int res;
+
+       res = ioctl (GPOINTER_TO_INT (handle), TIOCGWINSZ, &ws);
+
+       if (!res) {
+               *width = ws.ws_col;
+               *height = ws.ws_row;
+               return TRUE;
+       }
+       else
+               return FALSE;
+#else
+       return FALSE;
 #endif
+}
 
+#endif /* !PLATFORM_WIN32 */
index cc9b27f93866e49ea6663fe60ec5af24f85fbdf8..4f6cb871bda402268cfb75fd3da05d4e2cadcc6b 100644 (file)
@@ -23,6 +23,7 @@ gint32 ves_icall_System_ConsoleDriver_InternalKeyAvailable (gint32 timeout);
 MonoBoolean ves_icall_System_ConsoleDriver_SetEcho (MonoBoolean echo);
 MonoBoolean ves_icall_System_ConsoleDriver_SetBreak (MonoBoolean want_break);
 MonoBoolean ves_icall_System_ConsoleDriver_TtySetup (MonoString *teardown);
+MonoBoolean ves_icall_System_ConsoleDriver_GetTtySize (HANDLE handle, gint32 *width, gint32 *height);
 
 G_END_DECLS
 
index ad5a67d0f6da085e509478b0856038ad77b973c2..64b22c19287f7570a23e398551bc5f5d91d43cb2 100644 (file)
@@ -5445,6 +5445,7 @@ ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
 
        utf8_name = mono_string_to_utf8 (name); /* FIXME: this should be ascii */
        value = g_getenv (utf8_name);
+
        g_free (utf8_name);
 
        if (value == 0)
@@ -6340,6 +6341,7 @@ static const IcallEntry defaultconf_icalls [] = {
 };
 
 static const IcallEntry consoledriver_icalls [] = {
+       {"GetTtySize", ves_icall_System_ConsoleDriver_GetTtySize },
        {"InternalKeyAvailable", ves_icall_System_ConsoleDriver_InternalKeyAvailable },
        {"Isatty", ves_icall_System_ConsoleDriver_Isatty },
        {"SetBreak", ves_icall_System_ConsoleDriver_SetBreak },