|
LLVM
3.7.0
|
#include <LineEditor.h>
Classes | |
| struct | Completion |
| A possible completion at a given cursor position. More... | |
| struct | CompletionAction |
| The action to perform upon a completion request. More... | |
| struct | InternalData |
Public Member Functions | |
| LineEditor (StringRef ProgName, StringRef HistoryPath="", FILE *In=stdin, FILE *Out=stdout, FILE *Err=stderr) | |
| Create a LineEditor object. More... | |
| ~LineEditor () | |
| llvm::Optional< std::string > | readLine () const |
| Reads a line. More... | |
| void | saveHistory () |
| void | loadHistory () |
| template<typename T > | |
| void | setCompleter (T Comp) |
| Set the completer for this LineEditor. More... | |
| template<typename T > | |
| void | setListCompleter (T Comp) |
| Set the completer for this LineEditor to the given list completer. More... | |
| CompletionAction | getCompletionAction (StringRef Buffer, size_t Pos) const |
| Use the current completer to produce a CompletionAction for the given completion request. More... | |
| const std::string & | getPrompt () const |
| void | setPrompt (const std::string &P) |
Static Public Member Functions | |
| static std::string | getDefaultHistoryPath (StringRef ProgName) |
Definition at line 22 of file LineEditor.h.
| LineEditor::LineEditor | ( | StringRef | ProgName, |
| StringRef | HistoryPath = "", |
||
| FILE * | In = stdin, |
||
| FILE * | Out = stdout, |
||
| FILE * | Err = stderr |
||
| ) |
Create a LineEditor object.
| ProgName | The name of the current program. Used to form a default prompt. |
| HistoryPath | Path to the file in which to store history data, if possible. |
| In | The input stream used by the editor. |
| Out | The output stream used by the editor. |
| Err | The error stream used by the editor. |
Definition at line 193 of file LineEditor.cpp.
References llvm::Data, ElCompletionFn(), ElGetPromptFn(), llvm::StringRef::empty(), getDefaultHistoryPath(), llvm::tgtok::In, loadHistory(), and llvm::StringRef::str().
| LineEditor::~LineEditor | ( | ) |
Definition at line 229 of file LineEditor.cpp.
References saveHistory().
| LineEditor::CompletionAction LineEditor::getCompletionAction | ( | StringRef | Buffer, |
| size_t | Pos | ||
| ) | const |
Use the current completer to produce a CompletionAction for the given completion request.
If the current completer is a list completer, this will return an AK_Insert CompletionAction if each completion has a common prefix, or an AK_ShowCompletions CompletionAction otherwise.
| Buffer | The string to complete |
| Pos | The zero-based cursor position in the StringRef |
Definition at line 82 of file LineEditor.cpp.
References llvm::LineEditor::CompletionAction::AK_ShowCompletions, and llvm::LineEditor::CompletionAction::Kind.
Referenced by ElCompletionFn().
|
static |
Definition at line 22 of file LineEditor.cpp.
References llvm::sys::path::append(), llvm::sys::path::home_directory(), and llvm::SmallString< InternalLen >::str().
Referenced by LineEditor().
|
inline |
Definition at line 105 of file LineEditor.h.
Referenced by ElCompletionFn(), and ElGetPromptFn().
| void LineEditor::loadHistory | ( | ) |
Definition at line 244 of file LineEditor.cpp.
Referenced by LineEditor().
| Optional< std::string > LineEditor::readLine | ( | ) | const |
Reads a line.
Definition at line 251 of file LineEditor.cpp.
| void LineEditor::saveHistory | ( | ) |
Definition at line 237 of file LineEditor.cpp.
Referenced by ~LineEditor().
|
inline |
Set the completer for this LineEditor.
A completer is a function object which takes arguments of type StringRef (the string to complete) and size_t (the zero-based cursor position in the StringRef) and returns a CompletionAction.
Definition at line 84 of file LineEditor.h.
|
inline |
Set the completer for this LineEditor to the given list completer.
A list completer is a function object which takes arguments of type StringRef (the string to complete) and size_t (the zero-based cursor position in the StringRef) and returns a std::vector<Completion>.
Definition at line 92 of file LineEditor.h.
|
inline |
Definition at line 106 of file LineEditor.h.
References P.
1.8.6