I have written a simple FORTH-like interpreter where I get input a line at a time and process it like this:
std::string line;
while (!std::cin.eof()) {
std::getline(std::cin, line);
std::istringstream input(line);
std::copy(std::istream_iterator<std::string>(input),
std::istream_iterator<std::string>(),
std::back_inserter(data.input_));
// some work
}
And if I input 5 5 + . <enter>
it displays like this:
5 5 + .
10 ok
But what I would like it show is:
5 5 + . 10 ok
In other words a newline should be accepted to mean end of line input but it should not be echoed to std::cout.
Having done some reading it seems I will not be able to achieve this in std c++ (is this true?) but I can use the functions in the termios library to set up the console this way on a POSIX system without messing with other console functions such as ctl-c handling etc. I haven't figured out exactly how though. Can anyone show me the way?
You can Use VT100 Escape Sequences for customising console output (VT100 ESC SEQUENCES). in this case;
use
\033[1A
for go 1 line up,\033[nC
(n is int value) to Go n letter right