view src/readline-1-display.patch @ 4037:85abb6c3ec8b

of-netcdf: patch for --enable-64 (Bug #46060) * src/of-netcdf-1-fixes.patch: new file * dist-files.mk: add of-netcdf-1-fixes.patch
author John Donoghue <john.donoghue@ieee.org>
date Tue, 29 Sep 2015 19:43:19 -0400
parents 4ce61d3172f0
children
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