27#include "llvm/Support/FileSystem.h"
28#include "llvm/Support/Locale.h"
29#include "llvm/Support/Threading.h"
43int setupterm(
char *term,
int fildes,
int *errret);
45#define USE_SETUPTERM_WORKAROUND
56#define ANSI_CLEAR_BELOW ESCAPE "[J"
57#define ANSI_CLEAR_RIGHT ESCAPE "[K"
58#define ANSI_SET_COLUMN_N ESCAPE "[%dG"
59#define ANSI_UP_N_ROWS ESCAPE "[%dA"
60#define ANSI_DOWN_N_ROWS ESCAPE "[%dB"
62#if LLDB_EDITLINE_USE_WCHAR
64#define EditLineConstString(str) L##str
65#define EditLineStringFormatSpec "%ls"
69#define EditLineConstString(str) str
70#define EditLineStringFormatSpec "%s"
74#define history_w history
75#define history_winit history_init
76#define history_wend history_end
77#define HistoryW History
78#define HistEventW HistEvent
79#define LineInfoW LineInfo
81#define el_wgets el_gets
82#define el_wgetc el_getc
83#define el_wpush el_push
84#define el_wparse el_parse
87#define el_wline el_line
88#define el_winsertstr el_insertstr
89#define el_wdeletestr el_deletestr
94 for (
wchar_t ch : content) {
102 return llvm::sys::locale::columnWidth(str);
123 case HistoryOperation::Oldest:
125 case HistoryOperation::Older:
127 case HistoryOperation::Current:
129 case HistoryOperation::Newer:
131 case HistoryOperation::Newest:
134 llvm_unreachable(
"Fully covered switch!");
141 combined_stream << line.c_str() <<
"\n";
143 return combined_stream.str();
147 std::vector<EditLineStringType> result;
149 while (start < input.length()) {
150 size_t end = input.find(
'\n', start);
151 if (end == std::string::npos) {
152 result.push_back(input.substr(start));
155 result.push_back(input.substr(start, end - start));
160 if (result.empty()) {
161 result.emplace_back();
167 int indent_correction) {
168 if (indent_correction == 0)
170 if (indent_correction < 0)
171 return line.substr(-indent_correction);
191 const int fd = fileno(file);
193 select_helper.
SetTimeout(std::chrono::microseconds(0));
199namespace line_editor {
220 llvm::SmallString<128> lldb_history_file;
222 llvm::sys::path::append(lldb_history_file,
".lldb");
226 if (!llvm::sys::fs::create_directory(lldb_history_file)) {
227#if LLDB_EDITLINE_USE_WCHAR
228 std::string filename =
m_prefix +
"-widehistory";
230 std::string filename =
m_prefix +
"-history";
232 llvm::sys::path::append(lldb_history_file, filename);
233 m_path = std::string(lldb_history_file.str());
254 typedef std::map<std::string, EditlineHistoryWP> WeakHistoryMap;
255 static std::recursive_mutex g_mutex;
256 static WeakHistoryMap g_weak_map;
257 std::lock_guard<std::recursive_mutex> guard(g_mutex);
258 WeakHistoryMap::const_iterator pos = g_weak_map.find(prefix);
260 if (pos != g_weak_map.end()) {
261 history_sp = pos->second.lock();
264 g_weak_map.erase(pos);
267 g_weak_map[prefix] = history_sp;
321 std::max<int>(3, std::to_string(line_number).length() + 1);
327 if (use_line_numbers && prompt.length() == 0)
329 std::string continuation_prompt = prompt;
334 const size_t cont_prompt_width =
ColumnWidth(continuation_prompt);
335 const size_t padded_prompt_width =
336 std::max(prompt_width, cont_prompt_width);
337 if (prompt_width < padded_prompt_width)
338 prompt += std::string(padded_prompt_width - prompt_width,
' ');
339 else if (cont_prompt_width < padded_prompt_width)
340 continuation_prompt +=
341 std::string(padded_prompt_width - cont_prompt_width,
' ');
344 if (use_line_numbers) {
348 (line_index == 0) ? prompt.c_str() : continuation_prompt.c_str());
349 return std::string(std::move(prompt_stream.
GetString()));
351 return (line_index == 0) ? prompt : continuation_prompt;
364 return editor[0] ==
'e';
370 character < info->lastchar; character++) {
371 if (*character !=
' ')
379 if (location == CursorLocation::EditingPrompt ||
380 location == CursorLocation::BlockEnd ||
381 location == CursorLocation::EditingCursor) {
385 if (location == CursorLocation::EditingCursor) {
387 }
else if (location == CursorLocation::BlockEnd) {
400 int editline_cursor_position =
407 if (toLine != fromLine) {
410 std::abs(toLine - fromLine));
415 if (to == CursorLocation::EditingCursor) {
418 }
else if (to == CursorLocation::BlockEnd && !
m_input_lines.empty()) {
430 for (
int index = firstIndex; index < line_count; index++) {
437 if (index < line_count - 1)
445 int line_length = (int)(content.length() +
ColumnWidth(prompt));
460#if LLDB_EDITLINE_USE_WCHAR
471 assert(op == HistoryOperation::Older || op == HistoryOperation::Newer);
477 std::vector<EditLineStringType> new_input_lines;
482 case HistoryOperation::Newer:
484 case HistoryOperation::Older: {
497 llvm_unreachable(
"unsupported history direction");
502 case HistoryOperation::Older:
505 case HistoryOperation::Newer:
511 llvm_unreachable(
"unsupported history direction");
518 new_input_lines =
SplitLines(history_event.str);
521 MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart);
528 case HistoryOperation::Older:
531 case HistoryOperation::Newer:
535 llvm_unreachable(
"unsupported history direction");
538 MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt);
548 MoveCursor(CursorLocation::EditingCursor, CursorLocation::EditingPrompt);
555 MoveCursor(CursorLocation::EditingPrompt, CursorLocation::EditingCursor);
562 int lineLength = (int)((info->lastchar - info->buffer) +
GetPromptWidth());
566 MoveCursor(CursorLocation::EditingCursor, CursorLocation::EditingPrompt);
569 MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingCursor);
608 llvm_unreachable(
"Interrupts should have been handled above.");
635 auto new_line_fragment =
652#if LLDB_EDITLINE_USE_WCHAR
653 lines.
AppendString(m_utf8conv.to_bytes(new_line_fragment));
659 new_line_fragment =
FixIndentation(new_line_fragment, indent_correction);
667 MoveCursor(CursorLocation::EditingCursor, CursorLocation::EditingPrompt);
672 MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt);
690 info->cursor == info->lastchar) {
699 for (
unsigned index = 0; index < lines.GetSize(); index++) {
700#if LLDB_EDITLINE_USE_WCHAR
702 m_utf8conv.from_bytes(lines[index]));
709 MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockEnd);
719 if (info->cursor < info->lastchar) {
728 if (ch == 4 && info->buffer == info->lastchar) {
737 MoveCursor(CursorLocation::EditingCursor, CursorLocation::EditingPrompt);
742 info->cursor = cursor;
750 MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingCursor);
759 if (info->cursor > info->buffer) {
783 MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt);
796 MoveCursor(CursorLocation::EditingCursor, CursorLocation::EditingPrompt);
837 int cursor_position = (int)((info->cursor - info->buffer) +
GetPromptWidth());
866 int cursor_position = info->cursor - info->buffer;
871 int indent_correction =
875 if (indent_correction == 0)
880 if (indent_correction > 0) {
881 currentLine = currentLine.insert(0, indent_correction,
' ');
883 currentLine = currentLine.erase(0, -indent_correction);
885#if LLDB_EDITLINE_USE_WCHAR
892 MoveCursor(CursorLocation::EditingCursor, CursorLocation::EditingPrompt);
898 MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt);
908 if (info->cursor > info->lastchar) {
909 info->cursor = info->lastchar;
918 MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart);
926 MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockEnd);
928 MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt);
936 llvm::ArrayRef<CompletionResult::Completion> results,
939 fprintf(output_file,
"\t%-*s", (
int)max_len, c.GetCompletion().c_str());
940 if (!c.GetDescription().empty())
941 fprintf(output_file,
" -- %s", c.GetDescription().c_str());
942 fprintf(output_file,
"\n");
947 Editline &editline, llvm::ArrayRef<CompletionResult::Completion> results) {
948 assert(!results.empty());
952 const size_t page_size = 40;
956 std::max_element(results.begin(), results.end(), [](
auto &c1,
auto &c2) {
957 return c1.GetCompletion().size() < c2.GetCompletion().size();
960 const size_t max_len = longest->GetCompletion().size();
962 if (results.size() < page_size) {
968 while (cur_pos < results.size()) {
969 size_t remaining = results.size() - cur_pos;
970 size_t next_size = all ? remaining : std::min(page_size, remaining);
975 cur_pos += next_size;
977 if (cur_pos >= results.size())
997 if (got_char == -1 || reply ==
'n')
1008 const LineInfo *line_info = el_line(
m_editline);
1010 llvm::StringRef line(line_info->buffer,
1011 line_info->lastchar - line_info->buffer);
1012 unsigned cursor_index = line_info->cursor - line_info->buffer;
1018 llvm::ArrayRef<CompletionResult::Completion> results = result.
GetResults();
1023 if (results.size() == 0)
1026 if (results.size() == 1) {
1028 switch (completion.
GetMode()) {
1037 to_add.push_back(
' ');
1042 return CC_REDISPLAY;
1052 el_deletestr(
m_editline, line_info->cursor - line_info->buffer);
1057 return CC_REDISPLAY;
1062 if (!longest_prefix.empty())
1065 if (!longest_prefix.empty()) {
1066 el_insertstr(
m_editline, longest_prefix.c_str());
1067 return CC_REDISPLAY;
1073 MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingCursor);
1074 return CC_REDISPLAY;
1079 return CC_REDISPLAY;
1082 const LineInfo *line_info = el_line(
m_editline);
1083 llvm::StringRef line(line_info->buffer,
1084 line_info->lastchar - line_info->buffer);
1089 return CC_REDISPLAY;
1093 std::string typed = std::string(1, ch);
1097 return CC_REDISPLAY;
1100 const LineInfo *line_info = el_line(
m_editline);
1101 llvm::StringRef line(line_info->buffer,
1102 line_info->lastchar - line_info->buffer);
1105 std::string to_add_color =
1109 size_t new_autosuggestion_size = line.size() + to_add->length();
1112 size_t spaces_to_print =
1114 std::string spaces = std::string(spaces_to_print,
' ');
1119 int editline_cursor_position =
1120 (int)((line_info->cursor - line_info->buffer) +
GetPromptWidth());
1128 return CC_REDISPLAY;
1186 [](EditLine *editline,
int ch) {
1193 [](EditLine *editline,
int ch) {
1199 [](EditLine *editline,
int ch) {
1205 [](EditLine *editline,
int ch) {
1211 [](EditLine *editline,
int ch) {
1222 [](EditLine *editline,
int ch) {
1228 [](EditLine *editline,
int ch) {
1234 [](EditLine *editline,
int ch) {
1240 [](EditLine *editline,
int ch) {
1246 [](EditLine *editline,
int ch) {
1268 el_set(
m_editline, EL_BIND,
"^r",
"em-inc-search-prev",
1275 [](EditLine *editline,
int ch) {
1279 el_set(
m_editline, EL_BIND,
"^f",
"lldb-apply-complete",
1285 [](EditLine *editline,
int ch) {
1289 char bind_key[2] = {0, 0};
1290 llvm::StringRef ascii_chars =
1291 "abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXZY1234567890!\"#$%"
1292 "&'()*+,./:;<=>?@[]_`{|}~ ";
1293 for (
char c : ascii_chars) {
1295 el_set(
m_editline, EL_BIND, bind_key,
"lldb-typed-character", NULL);
1297 el_set(
m_editline, EL_BIND,
"\\-",
"lldb-typed-character", NULL);
1298 el_set(
m_editline, EL_BIND,
"\\^",
"lldb-typed-character", NULL);
1299 el_set(
m_editline, EL_BIND,
"\\\\",
"lldb-typed-character", NULL);
1303 el_set(
m_editline, EL_BIND,
"^w",
"ed-delete-prev-word",
1305 el_set(
m_editline, EL_BIND,
"\t",
"lldb-complete",
1325 [](EditLine *editline,
int ch) {
1331 char bind_key[2] = {0, 0};
1333 while (*indent_chars) {
1334 bind_key[0] = *indent_chars;
1335 el_set(
m_editline, EL_BIND, bind_key,
"lldb-fix-indentation", NULL);
1342 el_set(
m_editline, EL_BIND,
"\n",
"lldb-end-or-add-line", NULL);
1343 el_set(
m_editline, EL_BIND,
"\r",
"lldb-end-or-add-line", NULL);
1346 el_set(
m_editline, EL_BIND,
"^p",
"lldb-previous-line", NULL);
1347 el_set(
m_editline, EL_BIND,
"^n",
"lldb-next-line", NULL);
1348 el_set(
m_editline, EL_BIND,
"^?",
"lldb-delete-previous-char", NULL);
1349 el_set(
m_editline, EL_BIND,
"^d",
"lldb-delete-next-char", NULL);
1367 el_set(
m_editline, EL_BIND,
"^H",
"lldb-delete-previous-char", NULL);
1372 el_set(
m_editline, EL_BIND,
"-a",
"x",
"lldb-delete-next-char", NULL);
1373 el_set(
m_editline, EL_BIND,
"-a",
"^H",
"lldb-delete-previous-char",
1375 el_set(
m_editline, EL_BIND,
"-a",
"^?",
"lldb-delete-previous-char",
1380 el_set(
m_editline, EL_BIND,
"-a",
"[A",
"lldb-previous-line", NULL);
1381 el_set(
m_editline, EL_BIND,
"-a",
"[B",
"lldb-next-line", NULL);
1382 el_set(
m_editline, EL_BIND,
"-a",
"[\\^",
"lldb-revert-line", NULL);
1391 el_get(editline, EL_CLIENTDATA, &editor);
1396 FILE *output_file, FILE *error_file,
1397 std::recursive_mutex &output_mutex)
1399 m_output_file(output_file), m_error_file(error_file),
1400 m_input_connection(fileno(input_file), false),
1401 m_output_mutex(output_mutex) {
1403 m_editor_name = (editline_name ==
nullptr) ?
"lldb-tmp" : editline_name;
1406#ifdef USE_SETUPTERM_WORKAROUND
1409 if (term_fd != -1) {
1410 static std::recursive_mutex *g_init_terminal_fds_mutex_ptr =
nullptr;
1411 static std::set<int> *g_init_terminal_fds_ptr =
nullptr;
1412 static llvm::once_flag g_once_flag;
1413 llvm::call_once(g_once_flag, [&]() {
1414 g_init_terminal_fds_mutex_ptr =
1415 new std::recursive_mutex();
1417 g_init_terminal_fds_ptr =
new std::set<int>();
1424 std::lock_guard<std::recursive_mutex> guard(
1425 *g_init_terminal_fds_mutex_ptr);
1426 if (g_init_terminal_fds_ptr->find(term_fd) ==
1427 g_init_terminal_fds_ptr->end()) {
1428 g_init_terminal_fds_ptr->insert(term_fd);
1429 setupterm((
char *)0, term_fd, (
int *)0);
1459 continuation_prompt ==
nullptr ?
"" : continuation_prompt;
1477 if (el_get(
m_editline, EL_GETTC,
"co", &columns,
nullptr) == 0) {
1510 MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart);
1542 if (input ==
nullptr) {
1547#if LLDB_EDITLINE_USE_WCHAR
1548 line = m_utf8conv.to_bytes(
SplitLines(input)[0]);
1559 bool &interrupted) {
1572 MoveCursor(CursorLocation::BlockEnd, CursorLocation::BlockStart);
1601 MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart);
1604 stream->
Write(s, len);
1608 MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingCursor);
1613#if !LLDB_EDITLINE_USE_WCHAR
1614 if (ch == (
char)EOF)
1617 out = (
unsigned char)ch;
1620 std::codecvt_utf8<wchar_t> cvt;
1621 llvm::SmallString<4> input;
1623 const char *from_next;
1625 std::mbstate_t state = std::mbstate_t();
1626 input.push_back(ch);
1627 switch (cvt.in(state, input.begin(), input.end(), from_next, &out, &out + 1,
1629 case std::codecvt_base::ok:
1632 case std::codecvt_base::error:
1633 case std::codecvt_base::noconv:
1636 case std::codecvt_base::partial:
1639 &ch, 1, std::chrono::seconds(0), status,
nullptr);
1640 if (read_count == 0)
EditLineStringType CombineLines(const std::vector< EditLineStringType > &lines)
#define EditLineConstString(str)
static void PrintCompletion(FILE *output_file, llvm::ArrayRef< CompletionResult::Completion > results, size_t max_len)
Prints completions and their descriptions to the given file.
#define EditLineStringFormatSpec
EditLineStringType FixIndentation(const EditLineStringType &line, int indent_correction)
bool IsInputPending(FILE *file)
static size_t ColumnWidth(llvm::StringRef str)
#define ANSI_SET_COLUMN_N
std::vector< EditLineStringType > SplitLines(const EditLineStringType &input)
bool IsOnlySpaces(const EditLineStringType &content)
int GetIndentation(const EditLineStringType &line)
static int GetOperation(HistoryOperation op)
#define ESCAPE
https://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
lldb_private::Status Select()
void FDSetRead(lldb::socket_t fd)
void SetTimeout(const std::chrono::microseconds &timeout)
A command line argument class.
"lldb/Utility/ArgCompletionRequest.h"
const Args & GetParsedLine() const
llvm::StringRef GetCursorArgumentPrefix() const
const Args::ArgEntry & GetParsedArg()
size_t GetCursorIndex() const
A single completion and all associated data.
const std::string & GetCompletion() const
CompletionMode GetMode() const
llvm::ArrayRef< Completion > GetResults() const
void GetMatches(StringList &matches) const
Adds all collected completion matches to the given list.
bool InterruptRead() override
Interrupts an ongoing Read() operation.
size_t Read(void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr) override
The read function that attempts to read from the connection.
Instances of Editline provide an abstraction over libedit's EditLine facility.
IsInputCompleteCallbackType m_is_input_complete_callback
EditorStatus m_editor_status
unsigned char PreviousLineCommand(int ch)
Line navigation command used when ^P or up arrow are pressed in multi-line mode.
unsigned char RecallHistory(HistoryOperation op)
Replaces the current multi-line session with the next entry from history.
bool IsOnlySpaces()
Returns true if the current EditLine buffer contains nothing but spaces, or is empty.
void SaveEditedLine()
Save the line currently being edited.
void MoveCursor(CursorLocation from, CursorLocation to)
Move the cursor from one well-established location to another using relative line positioning and abs...
std::string m_suggestion_ansi_suffix
void SetGetCharacterFunction(EditlineGetCharCallbackType callbackFn)
bool m_needs_prompt_repaint
std::string m_current_prompt
static void DisplayCompletions(Editline &editline, llvm::ArrayRef< CompletionResult::Completion > results)
std::string m_set_continuation_prompt
std::size_t m_previous_autosuggestion_size
ConnectionFileDescriptor m_input_connection
unsigned char BufferStartCommand(int ch)
Buffer start command used when Esc < is typed in multi-line emacs mode.
const char * Prompt()
Prompt implementation for EditLine.
unsigned char EndOrAddLineCommand(int ch)
Command used when return is pressed in multi-line mode.
unsigned char DeletePreviousCharCommand(int ch)
Delete command used when backspace is pressed in multi-line mode.
int GetLineIndexForLocation(CursorLocation location, int cursor_row)
Helper method used by MoveCursor to determine relative line position.
std::string m_prompt_ansi_prefix
bool IsEmacs()
Returns true if the underlying EditLine session's keybindings are Emacs-based, or false if they are V...
CompleteCallbackType m_completion_callback
size_t GetPromptWidth()
Determines the width of the prompt in characters.
unsigned char PreviousHistoryCommand(int ch)
History navigation command used when Alt + up arrow is pressed in multi-line mode.
const char * m_fix_indentation_callback_chars
std::string m_editor_name
uint32_t GetCurrentLine()
Returns the index of the line currently being edited.
void DisplayInput(int firstIndex=0)
Clear from cursor position to bottom of screen and print input lines including prompts,...
int GetCharacter(EditLineGetCharType *c)
Character reading implementation for EditLine that supports our multi-line editing trickery.
int m_revert_cursor_index
void TerminalSizeChanged()
Call when the terminal size changes.
volatile std::sig_atomic_t m_terminal_size_has_changed
void SetEditLinePromptCallback(EditlinePromptCallbackType callbackFn)
EditlineHistorySP m_history_sp
static Editline * InstanceFor(::EditLine *editline)
Uses the user data storage of EditLine to retrieve an associated instance of Editline.
bool GetLine(std::string &line, bool &interrupted)
Prompts for and reads a single line of user input.
void SetCurrentLine(int line_index)
Sets the current line index between line edits to allow free movement between lines.
int CountRowsForLine(const EditLineStringType &content)
Counts the number of rows a given line of content will end up occupying, taking into account both the...
void ConfigureEditor(bool multiline)
Ensures that the current EditLine instance is properly configured for single or multi-line editing.
unsigned char NextLineCommand(int ch)
Line navigation command used when ^N or down arrow are pressed in multi-line mode.
void PrintAsync(Stream *stream, const char *s, size_t len)
std::vector< EditLineStringType > m_live_history_lines
void ApplyTerminalSizeChange()
void AddFunctionToEditLine(const EditLineCharType *command, const EditLineCharType *helptext, EditlineCommandCallbackType callbackFn)
std::vector< EditLineStringType > m_input_lines
bool CompleteCharacter(char ch, EditLineGetCharType &out)
bool Cancel()
Cancel this edit and obliterate all trace of it.
unsigned char DeleteNextCharCommand(int ch)
Delete command used when delete is pressed in multi-line mode.
std::string m_suggestion_ansi_prefix
SuggestionCallbackType m_suggestion_callback
unsigned char FixIndentationCommand(int ch)
Respond to normal character insertion by fixing line indentation.
unsigned char NextHistoryCommand(int ch)
History navigation command used when Alt + down arrow is pressed in multi-line mode.
void SetPrompt(const char *prompt)
Sets a string to be used as a prompt, or combined with a line number to form a prompt.
unsigned char BufferEndCommand(int ch)
Buffer end command used when Esc > is typed in multi-line emacs mode.
unsigned char TypedCharacter(int ch)
Command used when a character is typed.
unsigned char BreakLineCommand(int ch)
Line break command used when meta+return is pressed in multi-line mode.
FixIndentationCallbackType m_fix_indentation_callback
unsigned char ApplyAutosuggestCommand(int ch)
Apply autosuggestion part in gray as editline.
unsigned char TabCommand(int ch)
Context-sensitive tab insertion or code completion command used when the tab key is typed.
Editline(const char *editor_name, FILE *input_file, FILE *output_file, FILE *error_file, std::recursive_mutex &output_mutex)
std::recursive_mutex & m_output_mutex
void SetContinuationPrompt(const char *continuation_prompt)
Sets an alternate string to be used as a prompt for the second line and beyond in multi-line editing ...
unsigned m_current_line_index
StringList GetInputAsStringList(int line_count=UINT32_MAX)
Convert the current input lines into a UTF8 StringList.
std::string PromptForIndex(int line_index)
Returns the complete prompt by combining the prompt or continuation prompt with line numbers as appro...
unsigned char RevertLineCommand(int ch)
Revert line command used when moving between lines.
bool Interrupt()
Interrupt the current edit as if ^C was pressed.
const char * GetPrompt()
Returns the prompt established by SetPrompt.
void SetBaseLineNumber(int line_number)
Sets the lowest line number for multi-line editing sessions.
bool GetLines(int first_line_number, StringList &lines, bool &interrupted)
Prompts for and reads a multi-line batch of user input.
std::string m_prompt_ansi_suffix
bool GetHomeDirectory(llvm::SmallVectorImpl< char > &path) const
Get the user home directory.
static FileSystem & Instance()
bool Success() const
Test for success condition.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
virtual void Flush()=0
Flush the stream.
void AppendString(const std::string &s)
const char * GetStringAtIndex(size_t idx) const
std::string LongestCommonPrefix()
HistoryW * GetHistoryPtr()
void Enter(const EditLineCharType *line_cstr)
const char * GetHistoryFilePath()
std::string m_path
Path to the history file.
std::string m_prefix
The prefix name (usually the editline program name) to use when loading/saving history.
HistoryW * m_history
The history object.
EditlineHistory(const std::string &prefix, uint32_t size, bool unique_entries)
static EditlineHistorySP GetHistory(const std::string &prefix)
HistEventW m_event
The history event needed to contain all history events.
std::stringstream EditLineStringStreamType
std::weak_ptr< EditlineHistory > EditlineHistoryWP
unsigned char(*)(::EditLine *editline, int ch) EditlineCommandCallbackType
const char *(*)(::EditLine *editline) EditlinePromptCallbackType
int(*)(::EditLine *editline, EditLineGetCharType *c) EditlineGetCharCallbackType
std::string EditLineStringType
HistoryOperation
Operation for the history.
std::shared_ptr< EditlineHistory > EditlineHistorySP
EditorStatus
Status used to decide when and how to start editing another line in multi-line sessions.
@ Complete
Editing complete, returns the complete set of edited lines.
CursorLocation
Established locations that can be easily moved among with MoveCursor.
A class that represents a running process on the host machine.
@ Partial
The current token has been partially completed.
@ Normal
The current token has been completed.
@ RewriteLine
The full line has been rewritten by the completion.
ConnectionStatus
Connection Status Types.
@ eConnectionStatusError
Check GetError() for details.
@ eConnectionStatusInterrupted
Interrupted read.
@ eConnectionStatusTimedOut
Request timed out.
@ eConnectionStatusEndOfFile
End-of-file encountered.
@ eConnectionStatusSuccess
Success.
@ eConnectionStatusLostConnection
Lost connection while connected to a valid connection.
@ eConnectionStatusNoConnection
No connection.
bool IsQuoted() const
Returns true if this argument was quoted in any way.
char GetQuoteChar() const