Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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));
like image 262
Scienziatogm Avatar asked Jan 24 '26 10:01

Scienziatogm


1 Answers

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.

like image 145
joshwilsonvu Avatar answered Jan 27 '26 00:01

joshwilsonvu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!