0

I'm trying to print the current input on my console window, using printw and ncurses, but the first input doesn't give any problem, while the next inputs make the printw overlapping with the other text, as you can see in this image: https://i.stack.imgur.com/v0OsT.png

This is my code:

FCString::Sprintf(sOutput, TEXT("> %s%s"), *sInput, LINE_TERMINATOR);
printw(TCHAR_TO_ANSI(sOutput));
refresh();

The result of Sprintf is "mycommand\n", because LINE_TERMINATOR is \n, so in this case I'm doing printw("> help\n");

This is another screen of what is happening when entering an unknown command and using printw("> Unknown Command: %s", command); https://i.stack.imgur.com/go48X.png

Scienziatogm
  • 53
  • 1
  • 6
  • Perhaps you should be using a carriage-return/newline pair `"\r\n"` for the line terminator? Or the problem is that something somewhere translates the newline into a carriage-return/newline pair when it shouldn't? – Some programmer dude Jul 04 '19 at 14:43
  • @Someprogrammerdude if I use \r\n I get a blank black line as you can see here: https://imgur.com/i2nYlMc.png – Scienziatogm Jul 04 '19 at 14:48
  • Update: this seems like a problem with printw, because with printf it is working as expected: https://i.imgur.com/mFxl0GB.png – Scienziatogm Jul 04 '19 at 15:08
  • @TedLyngmo printw is the printf function of ncurses and it allows to set attributes to a normal printf function such as colors. If you look the function manual it says that the input parameter must be a const char*, and the TCHAR I'm using is taken from the Unreal Engine 4 source, so it's a char16_t in this case, not a wchar_t. – Scienziatogm Jul 04 '19 at 15:39

0 Answers0