Allow "stealing" unfinished input. Enables resetting as a side-effect.
This commit is contained in:
parent
7cffe5e49b
commit
e43f5dbaa5
@ -49,8 +49,8 @@ namespace textinput {
|
||||
}
|
||||
|
||||
void
|
||||
TextInput::TakeInput(std::string &input) {
|
||||
if (fLastReadResult != kRRReadEOLDelimiter
|
||||
TextInput::TakeInput(std::string &input, bool force) {
|
||||
if (!force && fLastReadResult != kRRReadEOLDelimiter
|
||||
&& fLastReadResult != kRREOF) {
|
||||
input.clear();
|
||||
return;
|
||||
@ -67,12 +67,14 @@ namespace textinput {
|
||||
|
||||
ReleaseInputOutput();
|
||||
|
||||
if (fLastReadResult == kRRReadEOLDelimiter) {
|
||||
if (force || fLastReadResult == kRRReadEOLDelimiter) {
|
||||
// Input has been taken, we can continue reading.
|
||||
fLastReadResult = kRRNone;
|
||||
// We will have to redraw the prompt, even if unchanged.
|
||||
fNeedPromptRedraw = true;
|
||||
} // else keep EOF.
|
||||
} else {
|
||||
fLastReadResult = kRREOF;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -69,7 +69,7 @@ namespace textinput {
|
||||
EReadResult GetReadState() const { return fLastReadResult; }
|
||||
char GetLastKey() const { return fLastKey; }
|
||||
const std::string& GetInput();
|
||||
void TakeInput(std::string& input); // Take and reset input
|
||||
void TakeInput(std::string& input, bool force = false); // Take and reset input
|
||||
bool AtEOL() const { return fLastReadResult == kRRReadEOLDelimiter || AtEOF(); }
|
||||
bool AtEOF() const { return fLastReadResult == kRREOF; }
|
||||
bool HavePendingInput() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user