class LineEditor

Declaration

class LineEditor { /* full declaration omitted */ };

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:22

Member Variables

private std::string Prompt
private std::string HistoryPath
private std::unique_ptr<InternalData> Data
private std::unique_ptr<const CompleterConcept> Completer

Method Overview

Methods

LineEditor(llvm::StringRef ProgName,
           llvm::StringRef HistoryPath = "",
           FILE* In = stdin,
           FILE* Out = stdout,
           FILE* Err = stderr)

Description

Create a LineEditor object.

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:33

Parameters

llvm::StringRef ProgName
The name of the current program. Used to form a default prompt.
llvm::StringRef HistoryPath = ""
Path to the file in which to store history data, if possible.
FILE* In = stdin
The input stream used by the editor.
FILE* Out = stdout
The output stream used by the editor.
FILE* Err = stderr
The error stream used by the editor.

llvm::LineEditor::CompletionAction
getCompletionAction(llvm::StringRef Buffer,
                    size_t Pos) const

Description

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.

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:103

Parameters

llvm::StringRef Buffer
The string to complete
size_t Pos
The zero-based cursor position in the StringRef

static std::string getDefaultHistoryPath(
    llvm::StringRef ProgName)

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:45

Parameters

llvm::StringRef ProgName

const std::string& getPrompt() const

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:105

void loadHistory()

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:43

llvm::Optional<std::string> readLine() const

Description

Reads a line.

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:40

Returns

The line, or llvm::Optional <std ::string>() on EOF.

void saveHistory()

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:42

template <typename T>
void setCompleter(T Comp)

Description

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.

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:84

Templates

T

Parameters

T Comp

template <typename T>
void setListCompleter(T Comp)

Description

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 >.

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:92

Templates

T

Parameters

T Comp

void setPrompt(const std::string& P)

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:106

Parameters

const std::string& P

~LineEditor()

Declared at: llvm/include/llvm/LineEditor/LineEditor.h:35