Search code examples
c++linuxunreal-engine4

How to set the last line in terminal fixed for input while the application is doing a lot of printf?


I want to set the last input line on my terminal as fixed, so that everything that is printed from the application doesn't interfere with the user's input. I'm making an Unreal Engine 4 plugin, but I need to manage the Linux terminal input.

I tried getting the input with cin, and it works, but I don't know how to separate the user's input from the application output.

std::string input;
getline(std::cin, input);
char inputchar[input.size() + 1];
strcpy(inputchar, input.c_str());
UE_LOG(LogServerConsole, Warning, TEXT("Current Input: %s"), *FString(inputchar));

Solution

  • On Linux, it is absolutely possible to do what you're asking using ANSI escape sequences. However, just because it is possible does not mean it is easy; these are very low-level primitives that have to be built up.

    Ncurses is a higher-level library for doing more complicated things in a terminal window. I encourage you to read about it here and many other places online to see if it meets your needs.