-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added a command line flag and associated code to support dumb terminals #99
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,9 @@ namespace cling { | |
UITabCompletion* Completion = | ||
new UITabCompletion(m_MetaProcessor->getInterpreter()); | ||
TI.SetCompletion(Completion); | ||
if (D->GetTERM() && strstr(D->GetTERM(), "dumb")) { | ||
TI.SetIsDumbTerm(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't this be done inside textinput itself? See below... |
||
} | ||
|
||
std::string Line; | ||
std::string Prompt("[cling]$ "); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,8 @@ namespace textinput { | |
void Detach(); | ||
void DisplayInfo(const std::vector<std::string>& Options); | ||
bool IsTTY() const { return fIsTTY; } | ||
void SetTERM(const char* TERM) { fTERM = TERM; }; | ||
const char* GetTERM() { return fTERM; }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These interfaces (nor the data member) should not be needed, see below. Instead we'd need an |
||
|
||
protected: | ||
TerminalDisplay(bool isTTY): | ||
|
@@ -83,6 +85,7 @@ namespace textinput { | |
size_t fWriteLen; // Length of output written. | ||
Pos fWritePos; // Current position of writing (temporarily != cursor) | ||
char fPrevColor; // currently configured color | ||
const char* fTERM; // terminal type | ||
}; | ||
} | ||
#endif // TEXTINPUT_TERMINALDISPLAY_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,7 @@ namespace textinput { | |
TerminalConfigUnix::Get().TIOS()->c_lflag |= ECHOCTL|ECHOKE|ECHOE; | ||
#endif | ||
const char* TERM = getenv("TERM"); | ||
SetTERM(TERM); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
if (TERM && strstr(TERM, "256")) { | ||
fNColors = 256; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
namespace textinput { | ||
TextInput::TextInput(Reader& reader, Display& display, | ||
const char* HistFile /* = 0 */): | ||
fIsDumbTerm(false), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't that a property of the |
||
fMasked(false), | ||
fAutoHistAdd(true), | ||
fLastKey(0), | ||
|
@@ -61,9 +62,11 @@ namespace textinput { | |
} | ||
fContext->GetEditor()->ResetText(); | ||
|
||
// Signal displays that the input got taken. | ||
std::for_each(fContext->GetDisplays().begin(), fContext->GetDisplays().end(), | ||
std::mem_fun(&Display::NotifyResetInput)); | ||
if (!fIsDumbTerm) { | ||
// Signal displays that the input got taken. | ||
std::for_each(fContext->GetDisplays().begin(), fContext->GetDisplays().end(), | ||
std::mem_fun(&Display::NotifyResetInput)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
} | ||
|
||
ReleaseInputOutput(); | ||
|
||
|
@@ -124,7 +127,9 @@ namespace textinput { | |
|| (*iR)->HaveBufferedInput()) { | ||
if ((*iR)->ReadInput(nRead, in)) { | ||
ProcessNewInput(in, R); | ||
DisplayNewInput(R, OldCursorPos); | ||
if (!IsDumbTerm()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd move that |
||
DisplayNewInput(R, OldCursorPos); | ||
} | ||
if (fLastReadResult == kRREOF | ||
|| fLastReadResult == kRRReadEOLDelimiter) | ||
break; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,13 @@ namespace textinput { | |
void EnableAutoHistAdd(bool enable = true) { fAutoHistAdd = enable; } | ||
void AddHistoryLine(const char* line); | ||
|
||
// Dumb terminal getter and setter | ||
bool IsDumbTerm() const {return fIsDumbTerm;} | ||
void SetIsDumbTerm(bool isDumbTerm) { fIsDumbTerm = isDumbTerm; } | ||
|
||
protected: | ||
bool fIsDumbTerm; // whether this is a dumb terminal or not | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should all be moved to |
||
|
||
private: | ||
void EmitSignal(char c, EditorRange& r); | ||
void ProcessNewInput(const InputData& in, EditorRange& r); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the changes in this file from this PR?