34 #include "lib/charval.h" 35 #include "lib/aengine.h" 36 #include "main/evaluator.h" 42 TermiosConsole::TermiosConsole(
const char* prompt,
CharValidator* validator) :
48 TermiosConsole::~TermiosConsole()
53 bool TermiosConsole::Open()
55 if (tcgetattr(STDIN_FILENO, &oldAttr) != 0)
62 newAttr.c_lflag &=(~ICANON & ~ECHO);
63 newAttr.c_cc[VMIN] = 1;
64 newAttr.c_cc[VTIME] = 0;
66 return (tcsetattr(STDIN_FILENO, TCSANOW, &newAttr) != -1);
69 void TermiosConsole::Close()
73 tcsetattr(STDIN_FILENO, TCSANOW, &oldAttr);
77 void TermiosConsole::Start()
94 void TermiosConsole::Exit()
99 void TermiosConsole::ReadLine()
105 ssize_t res = read(STDIN_FILENO, &c,
sizeof(
char));
119 void TermiosConsole::WriteString(
const char* string)
124 void TermiosConsole::Write(
const char* string,
unsigned int length)
126 ssize_t res = write(STDOUT_FILENO, string, length);
127 if (res != (ssize_t)length)
133 void TermiosConsole::SetPrompt(
const char* string)
ConsoleBase(const char *prompt)
Abstract base class encapsulating console logic.
const char * GetLine() const
AnsiConoleEngine(const char *prompt, CharValidator *validator)
virtual void ResetConsole()
Evaluator(const char *input)
virtual void SetPrompt(const char *string)
void SetPrompt(const char *string)
int StrLen(const char *string)
Get the length of a null terminated string.
const char * ProcessChar(const unsigned char character)
virtual void StartMessage()