[Lldb-commits] [PATCH] D18335: Fix for missing prompt on Windows

Ted Woodward via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 23 12:24:58 PDT 2016


ted updated this revision to Diff 51462.
ted added a comment.

Updated to change cursor position before async output so old prompt is overwritten.

Adrian, please test with your setup and let me know if it solves the issues you see.


http://reviews.llvm.org/D18335

Files:
  source/Core/IOHandler.cpp

Index: source/Core/IOHandler.cpp
===================================================================
--- source/Core/IOHandler.cpp
+++ source/Core/IOHandler.cpp
@@ -52,6 +52,10 @@
 #include "lldb/Target/StackFrame.h"
 #endif
 
+#ifdef _MSC_VER
+#include <Windows.h>
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -794,7 +798,26 @@
         m_editline_ap->PrintAsync(stream, s, len);
     else
 #endif
+    {
+        const char *prompt = GetPrompt();
+#ifdef _MSC_VER
+        if (prompt)
+        {
+            // Back up over previous prompt using Windows API
+            CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
+            HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
+            GetConsoleScreenBufferInfo(console_handle, &screen_buffer_info);
+            COORD coord = screen_buffer_info.dwCursorPosition;
+            coord.X -= strlen(prompt);
+            if (coord.X < 0)
+                coord.X = 0;
+            SetConsoleCursorPosition(console_handle, coord);
+        }
+#endif
         IOHandler::PrintAsync(stream, s, len);
+        if (prompt)
+            IOHandler::PrintAsync(GetOutputStreamFile().get(), prompt, strlen(prompt));
+    }
 }
 
 // we may want curses to be disabled for some builds


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18335.51462.patch
Type: text/x-patch
Size: 1262 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160323/84821fc7/attachment.bin>


More information about the lldb-commits mailing list