diff liboctave/system/lo-sysdep.cc @ 16475:0696dcc92fc8

allow windows console to be cleared * lo-sysdep.h, lo-sysdep.cc (w32_clear_console_window): New function. * cmd-edit.cc (gnu_readline::do_clear_screen): Use it. * oct-rl-edit.c (octave_rl_clear_screen): Don't call system ("cls"). to clear screen on windows systems.
author John W. Eaton <jwe@octave.org>
date Tue, 09 Apr 2013 03:08:18 -0400
parents 0723ea02dcdb
children 98155e2b6d42
line wrap: on
line diff
--- a/liboctave/system/lo-sysdep.cc
+++ b/liboctave/system/lo-sysdep.cc
@@ -140,4 +140,37 @@
   return pid;
 }
 
+void
+w32_clear_console_window (void)
+{
+  HANDLE console = GetStdHandle (STD_OUTPUT_HANDLE);
+
+  // Get the number of character cells in the current buffer.
+
+  CONSOLE_SCREEN_BUFFER_INFO csbi; 
+
+  if (GetConsoleScreenBufferInfo (console, &csbi))
+    {
+      DWORD screen_size = csbi.dwSize.X * csbi.dwSize.Y;
+
+      // Fill the entire screen with blanks.
+
+      COORD home = { 0, 0 };
+      DWORD nchars;
+
+      if (FillConsoleOutputCharacter (console, static_cast<TCHAR> (' '),
+                                      screen_size, home, &nchars))
+        {
+          if (GetConsoleScreenBufferInfo (console, &csbi))
+            {
+              if (FillConsoleOutputAttribute (console, csbi.wAttributes,
+                                              screen_size, home, &nchars))
+                {
+                  SetConsoleCursorPosition (console, home);
+                }
+            }
+        }
+    }
+}
+
 #endif