Code complete only input coming from tty as reported by Reader.

This commit is contained in:
CristinaCristescu 2016-07-19 16:16:32 +02:00 committed by Axel Naumann
parent e43f5dbaa5
commit 0a895426d2
4 changed files with 9 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "textinput/Callbacks.h"
#include "textinput/History.h"
#include "textinput/KeyBinding.h"
#include "textinput/StreamReaderUnix.h"
#include "textinput/TextInput.h"
#include "textinput/TextInputContext.h"
@ -449,6 +450,9 @@ namespace textinput {
ProcessMove(kMoveEnd, R);
std::vector<std::string> completions;
TabCompletion* tc = fContext->GetCompletion();
Reader* reader = fContext->GetReaders()[0];
StreamReaderUnix* streamReader = (StreamReaderUnix*)(reader);
if (!streamReader->IsFromTTY()) return kPRSuccess;
if (tc) {
bool ret = tc->Complete(Line, Cursor, R, completions);
if (ret) {

View File

@ -38,6 +38,8 @@ namespace textinput {
virtual bool HavePendingInput(bool wait) = 0;
virtual bool HaveBufferedInput() const { return false; }
virtual bool ReadInput(size_t& nRead, InputData& in) = 0;
virtual bool IsFromTTY() = 0;
private:
TextInputContext* fContext; // Context object
};

View File

@ -36,6 +36,7 @@ namespace textinput {
bool HaveBufferedInput() const { return !fReadAheadBuffer.empty(); }
bool ReadInput(size_t& nRead, InputData& in);
bool IsFromTTY() override { return fIsTTY; }
private:
int ReadRawCharacter();
bool ProcessCSI(InputData& in);

View File

@ -31,6 +31,8 @@ namespace textinput {
bool HavePendingInput(bool wait);
bool ReadInput(size_t& nRead, InputData& in);
bool IsFromTTY() override { return fIsConsole; }
private:
void HandleError(const char* Where) const;
void HandleKeyEvent(unsigned char C, InputData& in);