3

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));
Scienziatogm
  • 53
  • 1
  • 6
  • Not possible with standard C++, which has nothing to say about terminals. I guess you have to look to some Linux library. – john Jul 02 '19 at 13:48

1 Answers1

1

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.

joshwilsonvu
  • 2,569
  • 9
  • 20
  • Thank you! I tried to include pdcurses library with Visual Studio 2019 but I'm getting undefined symbol: initscr even if I included curses.h – Scienziatogm Jul 02 '19 at 14:35
  • Are you linking with `-lncurses`? https://stackoverflow.com/questions/16192087/undefined-reference-to-initscr-ncurses – joshwilsonvu Jul 02 '19 at 14:42
  • I'm cross compiling with clang for windows, because I'm using Unreal Engine 4, so how can I do that? – Scienziatogm Jul 02 '19 at 15:32
  • Not sure. If you have access to the compiler options, just add `-lncurses` to the end. See if [this](https://forums.unrealengine.com/development-discussion/c-gameplay-programming/3268-how-to-specify-compiler-and-compiler-options) helps. – joshwilsonvu Jul 02 '19 at 16:16
  • Ok, I think that the real problem is how to compile pdcurses on windows and produce a .so library. I downloaded gnuwin32 but when I compile with make, I get this error: https://i.imgur.com/rwVOpWB.png – Scienziatogm Jul 02 '19 at 16:35
  • The translation is: "Cannot find the specified file" – Scienziatogm Jul 02 '19 at 16:45
  • This is starting to become a different question. I suggest opening a new question to fix the make error, but only after you research to make sure your question has not already been answered. – joshwilsonvu Jul 02 '19 at 16:50