view src/readline-1-display.patch @ 2988:aca8511e7751

qt.mk: link to correct files in bin directory
author John W. Eaton <jwe@octave.org>
date Thu, 16 May 2013 13:32:57 -0400
parents 2cf09b449d88
children 4ce61d3172f0
line wrap: on
line source

diff -uNr a/display.c b/display.c
--- a/display.c	2009-09-26 14:37:33.000000000 -0400
+++ b/display.c	2013-04-17 17:51:18.323642508 -0400
@@ -55,6 +55,11 @@
 #include "rlprivate.h"
 #include "xmalloc.h"
 
+#if defined (_WIN32)
+#include <windows.h>
+#define hStdout GetStdHandle(STD_OUTPUT_HANDLE)
+#endif
+
 #if !defined (strchr) && !defined (__STDC__)
 extern char *strchr (), *strrchr ();
 #endif /* !strchr && !__STDC__ */
@@ -1904,6 +1909,20 @@
   int cpos, dpos;		/* current and desired cursor positions */
   int adjust;
 
+#if defined (_WIN32)
+  CONSOLE_SCREEN_BUFFER_INFO csbi;
+  if (_rl_last_c_pos != new
+      && GetConsoleScreenBufferInfo (hStdout, &csbi))
+    {
+      csbi.dwCursorPosition.X += new - _rl_last_c_pos;
+      if (SetConsoleCursorPosition(hStdout, csbi.dwCursorPosition))
+        {
+          _rl_last_c_pos = new;
+          return;
+        }
+    }
+#endif /* !_WIN32 */
+	     
   woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
   cpos = _rl_last_c_pos;
 
@@ -2040,6 +2059,20 @@
 {
   register int delta, i;
 
+#if defined (_WIN32)
+  CONSOLE_SCREEN_BUFFER_INFO csbi;
+  if (_rl_last_v_pos != to && to <= _rl_screenheight
+      && GetConsoleScreenBufferInfo(hStdout, &csbi))
+    {
+      csbi.dwCursorPosition.Y += to - _rl_last_v_pos;
+      if (SetConsoleCursorPosition(hStdout, csbi.dwCursorPosition))
+        {
+          _rl_last_v_pos = to;
+          return;
+        }
+    }
+#endif /* !_WIN32 */
+
   if (_rl_last_v_pos == to || to > _rl_screenheight)
     return;
 
@@ -2318,6 +2351,17 @@
 _rl_clear_to_eol (count)
      int count;
 {
+#if defined (_WIN32)
+  CONSOLE_SCREEN_BUFFER_INFO csbi;
+  if (GetConsoleScreenBufferInfo (hStdout, &csbi))
+    {
+      DWORD written;
+      FillConsoleOutputCharacter(hStdout, ' ', count, csbi.dwCursorPosition,
+                                 &written);
+      return;
+    }
+#endif /* !_WIN32 */
+
   if (_rl_term_clreol)
     tputs (_rl_term_clreol, 1, _rl_output_character_function);
   else if (count)
@@ -2341,6 +2385,33 @@
 void
 _rl_clear_screen ()
 {
+#if defined (_WIN32)
+  COORD coordScreen = { 0, 0 };
+  DWORD cCharsWritten;
+  CONSOLE_SCREEN_BUFFER_INFO csbi; 
+  DWORD dwConSize;
+
+  if (GetConsoleScreenBufferInfo (hStdout, &csbi))
+    {
+      dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
+
+      if (FillConsoleOutputCharacter (hStdout, (TCHAR) ' ', dwConSize,
+                                      coordScreen, &cCharsWritten))
+        {
+          if (GetConsoleScreenBufferInfo (hStdout, &csbi))
+            {
+              if (FillConsoleOutputAttribute (hStdout, csbi.wAttributes,
+                                              dwConSize, coordScreen,
+                                              &cCharsWritten))
+                {
+                  SetConsoleCursorPosition (hStdout, coordScreen);
+                  return;
+                }
+            }
+        }
+    }
+#endif
+
   if (_rl_term_clrpag)
     tputs (_rl_term_clrpag, 1, _rl_output_character_function);
   else
@@ -2353,7 +2424,7 @@
      char *string;
      int count, col;
 {
-#if defined (__MSDOS__) || defined (__MINGW32__)
+#if defined (__MSDOS__) || (defined (__MINGW32__) && !defined (_MSC_VER))
   _rl_output_some_chars (string, count);
 #else
   /* DEBUGGING */
@@ -2405,7 +2476,7 @@
   if (count > _rl_screenwidth)	/* XXX */
     return;
 
-#if !defined (__MSDOS__) && !defined (__MINGW32__)
+#if (!defined (__MSDOS__) && !defined (__MINGW32__)) || defined (_MSC_VER)
   if (_rl_term_DC && *_rl_term_DC)
     {
       char *buffer;