My problem is that I want to do a special thing when my user is pushing tabulation in the terminal. My first code explains that :
char buffer[100];
while (true)
{
std::cin.getline(buffer, 100); // do IMMEDIATELY something if 'tabulation' was used ?
}
So I asked myself how to check every chars ? I tried with _getch();
while (true)
{
c = _getch();
if (c == '\t')
// do something special
else
std::cout << (char)c;
}
But now, I can't use any specials functions keys as arrows, del, suppr, etc... I can't move into what am I typing as I can with getline()
So is there any solutions to do a special interruption in a middle of a getline()
?
Or is it possible to use _getch()
in a different way ?
I also tried to do an other thread (one with getline()
and the other with _getch()
for checking every ) but I'm not so sure about what I can do with threads.
It could be possible to handle every special function (arrows keys, del, suppr, etc...) 'manually' but I'm looking for another solution.