|
14 | 14 | #include "lldb/Host/Editline.h" |
15 | 15 | #include "lldb/Host/FileSystem.h" |
16 | 16 | #include "lldb/Host/Host.h" |
| 17 | +#include "lldb/Utility/AnsiTerminal.h" |
17 | 18 | #include "lldb/Utility/CompletionRequest.h" |
18 | 19 | #include "lldb/Utility/FileSpec.h" |
19 | 20 | #include "lldb/Utility/LLDBAssert.h" |
@@ -85,7 +86,8 @@ bool IsOnlySpaces(const EditLineStringType &content) { |
85 | 86 | } |
86 | 87 |
|
87 | 88 | static size_t ColumnWidth(llvm::StringRef str) { |
88 | | - return llvm::sys::locale::columnWidth(str); |
| 89 | + std::string stripped = ansi::StripAnsiTerminalCodes(str); |
| 90 | + return llvm::sys::locale::columnWidth(stripped); |
89 | 91 | } |
90 | 92 |
|
91 | 93 | static int GetOperation(HistoryOperation op) { |
@@ -610,7 +612,7 @@ int Editline::GetCharacter(EditLineGetCharType *c) { |
610 | 612 | } |
611 | 613 |
|
612 | 614 | const char *Editline::Prompt() { |
613 | | - if (!m_prompt_ansi_prefix.empty() || !m_prompt_ansi_suffix.empty()) |
| 615 | + if (m_color) |
614 | 616 | m_needs_prompt_repaint = true; |
615 | 617 | return m_current_prompt.c_str(); |
616 | 618 | } |
@@ -1471,11 +1473,11 @@ Editline *Editline::InstanceFor(EditLine *editline) { |
1471 | 1473 | } |
1472 | 1474 |
|
1473 | 1475 | Editline::Editline(const char *editline_name, FILE *input_file, |
1474 | | - FILE *output_file, FILE *error_file, |
| 1476 | + FILE *output_file, FILE *error_file, bool color, |
1475 | 1477 | std::recursive_mutex &output_mutex) |
1476 | 1478 | : m_editor_status(EditorStatus::Complete), m_input_file(input_file), |
1477 | 1479 | m_output_file(output_file), m_error_file(error_file), |
1478 | | - m_input_connection(fileno(input_file), false), |
| 1480 | + m_input_connection(fileno(input_file), false), m_color(color), |
1479 | 1481 | m_output_mutex(output_mutex) { |
1480 | 1482 | // Get a shared history instance |
1481 | 1483 | m_editor_name = (editline_name == nullptr) ? "lldb-tmp" : editline_name; |
|
0 commit comments