(initialize_w32_display): Detect when the console
authorJason Rumney <jasonr@gnu.org>
Wed, 6 Jul 2005 21:36:31 +0000 (21:36 +0000)
committerJason Rumney <jasonr@gnu.org>
Wed, 6 Jul 2005 21:36:31 +0000 (21:36 +0000)
dimensions are insane, and default to 80x25 instead.
(w32_use_full_screen_buffer): default to NIL.

src/ChangeLog
src/w32console.c

index fcbc03a..4be86b6 100644 (file)
@@ -1,3 +1,9 @@
+2005-07-06  Jason Rumney  <jasonr@gnu.org>
+
+       * w32console.c (initialize_w32_display): Detect when the console
+       dimensions are insane, and default to 80x25 instead.
+       (w32_use_full_screen_buffer): default to NIL.
+
 2005-07-06  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
        * macterm.c (mac_draw_vertical_window_border): Use foreground of
index 70578f5..0ebda17 100644 (file)
@@ -635,7 +635,24 @@ initialize_w32_display (void)
   meta_key = 1;
   char_attr_normal = info.wAttributes;
 
-  if (w32_use_full_screen_buffer)
+  /* Determine if the info returned by GetConsoleScreenBufferInfo
+     is realistic.  Old MS Telnet servers used to only fill out
+     the dwSize portion, even modern one fill the whole struct with
+     garbage when using non-MS telnet clients.  */
+  if ((w32_use_full_screen_buffer
+       && (info.dwSize.Y < 20 || info.dwSize.Y > 100
+          || info.dwSize.X < 40 || info.dwSize.X > 200))
+      || (!w32_use_full_screen_buffer
+         && (info.srWindow.Bottom - info.srWindow.Top < 20
+             || info.srWindow.Bottom - info.srWindow.Top > 100
+             || info.srWindow.Right - info.srWindow.Left < 40
+             || info.srWindow.Right - info.srWindow.Left > 100)))
+    {
+      FRAME_LINES (SELECTED_FRAME ()) = 25;
+      SET_FRAME_COLS (SELECTED_FRAME (), 80);
+    }
+
+  else if (w32_use_full_screen_buffer)
     {
       FRAME_LINES (SELECTED_FRAME ()) = info.dwSize.Y; /* lines per page */
       SET_FRAME_COLS (SELECTED_FRAME (), info.dwSize.X);  /* characters per line */
@@ -691,7 +708,7 @@ This is desirable when running Emacs over telnet, and is the default.
 A value of nil means use the current console window dimensions; this
 may be preferrable when working directly at the console with a large
 scroll-back buffer.  */);
-  w32_use_full_screen_buffer = 1;
+  w32_use_full_screen_buffer = 0;
 
   defsubr (&Sset_screen_color);
   defsubr (&Sset_cursor_size);