Added the concept of a Read-Eval-Print-Loop to LLDB.
A REPL takes over the command line and typically treats input as source code.
REPLs can also do code completion. The REPL class allows its subclasses to
implement the language-specific functionality without having to know about the
IOHandler-specific internals.
Also added a PluginManager-based way of getting to a REPL given a language and
a target.
Also brought in some utility code and expression options that are useful for
REPLs, such as line offsets for expressions, ANSI terminal coloring of errors,
and a few IOHandler convenience functions.
llvm-svn: 250753
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp
index a3d7bf5..71a6149 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -22,6 +22,8 @@
#include <sys/ioctl.h>
#endif
+#include "llvm/Support/Process.h" // for llvm::sys::Process::FileDescriptorHasColors()
+
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Log.h"
@@ -1051,7 +1053,11 @@
if (::ioctl (fd, TIOCGWINSZ, &window_size) == 0)
{
if (window_size.ws_col > 0)
+ {
m_is_real_terminal = eLazyBoolYes;
+ if (llvm::sys::Process::FileDescriptorHasColors(fd))
+ m_supports_colors = eLazyBoolYes;
+ }
}
}
#endif
@@ -1074,3 +1080,11 @@
return m_is_real_terminal == eLazyBoolYes;
}
+bool
+File::GetIsTerminalWithColors ()
+{
+ if (m_supports_colors == eLazyBoolCalculate)
+ CalculateInteractiveAndTerminal();
+ return m_supports_colors == eLazyBoolYes;
+}
+