class ModalLineInput

Defined at line 38 of file ../../src/lib/line_input/modal_line_input.h

Manages multiple line input objects to manage regular input and temporary modal input for

questions. This is a base class, it delegates to a derived class to provide the line editor

implementations for different I/O schemes.

Public Methods

void ~ModalLineInput ()

Defined at line 62 of file ../../src/lib/line_input/modal_line_input.h

void ModalLineInput (Factory factory)

The constructor takes a factory function for the underlying LineInput types. These are used

to actually get input for the normal case and the modal input case. By default (null factory

function), a "stdout" line input will be used which is the expected behavior. Replacing the

line input implementation allows tests to use this class without using stdout.

Must call Init() before using any functions.

Defined at line 76 of file ../../src/lib/line_input/modal_line_input.cc

void Init (AcceptCallback accept_cb, const std::string & prompt)

This can't be in the constructor because it needs to call virtual functions.

Defined at line 85 of file ../../src/lib/line_input/modal_line_input.cc

void SetAutocompleteCallback (AutocompleteCallback cb)

LineInput implementation.

Defined at line 92 of file ../../src/lib/line_input/modal_line_input.cc

void SetChangeCallback (ChangeCallback cb)

Defined at line 98 of file ../../src/lib/line_input/modal_line_input.cc

void SetCancelCallback (CancelCallback cb)

Defined at line 104 of file ../../src/lib/line_input/modal_line_input.cc

void SetEofCallback (EofCallback cb)

Defined at line 109 of file ../../src/lib/line_input/modal_line_input.cc

void SetMaxCols (size_t max)

Defined at line 111 of file ../../src/lib/line_input/modal_line_input.cc

const std::string & GetLine ()

Defined at line 120 of file ../../src/lib/line_input/modal_line_input.cc

const std::deque<std::string> & GetHistory ()

Defined at line 122 of file ../../src/lib/line_input/modal_line_input.cc

void OnInput (char c)

Defined at line 128 of file ../../src/lib/line_input/modal_line_input.cc

void AddToHistory (const std::string & line)

Defined at line 134 of file ../../src/lib/line_input/modal_line_input.cc

void Hide (InterruptHandlingBehavior behavior)

Defined at line 139 of file ../../src/lib/line_input/modal_line_input.cc

void Show ()

Defined at line 144 of file ../../src/lib/line_input/modal_line_input.cc

void SetCurrentInput (const std::string & input)

Defined at line 149 of file ../../src/lib/line_input/modal_line_input.cc

void ModalGetOption (const ModalPromptOptions & options, const std::string & prompt, ModalCompletionCallback cb, WillShowModalCallback will_show)

Higher-level version of BeginModal() and EndModal() that takes a list of possible options and

will call the callback only when the user enters a match for one of the options. The completion

callback should not need to call EndModal(), it will be done automatically when a valid input

is selected.

Defined at line 153 of file ../../src/lib/line_input/modal_line_input.cc

void BeginModal (const std::string & prompt, ModalCompletionCallback cb, WillShowModalCallback will_show)

Begins a modal question with the given prompt. The normal prompt will be hidden and replaced

with the given one. The callback (see definition above for implementation requirements) will be

called when the user presses enter. This callback should call EndModal() if the input is

accepted.

There can be multiple callbacks happening at the same time. If there is a current modal input

active at the time of this call, the new one will be added to a queue and will be shown when

when the modal prompts before it have been completed.

The "will show" callback may be called from within this function (see its definition above).

Defined at line 171 of file ../../src/lib/line_input/modal_line_input.cc

void EndModal ()

Closes the current modal entry. If there is another modal prompt in the queue, it will be

shown. If there is none, the normal prompt will be shown again.

Normally this will be called from within the completion callback of BeginModal() when the

input is accepted.

Defined at line 188 of file ../../src/lib/line_input/modal_line_input.cc