RonShortt Posted August 7, 2021 Share Posted August 7, 2021 My program is working fine in Windows when I use '\n' in a c++ string to get a newline in the text of a label. I have now compiled it on Linux and the newline character is displayed as a character block as if the character cannot be displayed. Is there a way to get Linux to execute the same way as Windows. Here is sample code (a slightly modified version of the label sample code)? #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0]); //Create User Interface auto ui = CreateInterface(window); //Create widget auto label1 = CreateLabel("Label", 20, 20, 120, 30, ui->root); auto label2 = CreateLabel("Border\nLabel", 20, 50, 120, 60, ui->root, LABEL_BORDER | LABEL_CENTER | LABEL_MIDDLE); while (window->Closed() == false) { WaitEvent(); } return 0; } Quote Link to comment Share on other sites More sharing options...
Roland Posted August 7, 2021 Share Posted August 7, 2021 Have you tested std::endl https://en.cppreference.com/w/cpp/io/manip/endl Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
RonShortt Posted August 7, 2021 Author Share Posted August 7, 2021 3 hours ago, Roland said: Have you tested std::endl https://en.cppreference.com/w/cpp/io/manip/endl Unfortunately std::endl operates on the output I/O system rather than providing a newline character. According to the link you provided: Quote Inserts a newline character into the output sequence os and flushes it as if by calling os.put(os.widen('\n')) followed by os.flush(). This is an output-only I/O manipulator, it may be called with an expression such as out << std::endl for any out of type std::basic_ostream. 1 Quote Link to comment Share on other sites More sharing options...
Roland Posted August 7, 2021 Share Posted August 7, 2021 Just a thought. Might something like this work. Change the return values of newline to whatever suitable Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
RonShortt Posted August 7, 2021 Author Share Posted August 7, 2021 I have used GetText to retrieve the text after it is (improperly) displayed and printed it via cout and the newline in the returned string works as expected. The issue seems to be that the Linux library is not dealing with the newline in the same (proper) manner as the Windows library. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted August 8, 2021 Share Posted August 8, 2021 Hmmm, I think the GDI+ (Windows) handles line returns automatically and XRender must not...let me see if there is a way... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
RonShortt Posted August 8, 2021 Author Share Posted August 8, 2021 Thanks, Josh. I appreciate it!! Quote Link to comment Share on other sites More sharing options...
RonShortt Posted August 8, 2021 Author Share Posted August 8, 2021 So I dug out my 30 year old copy of Introduction to the X Window System (Updated for XVIIR4) and started reading. In the section on fonts it says: Quote If there is any special action to be taken for control characters, the application must be programmed to take it explicitly. That would indicate that either Ultra App Kit or my program must deal with the newline character as the X Window system simply treats it as just another (unprintable) character. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted August 8, 2021 Share Posted August 8, 2021 I think this is a matter of design then. Under what circumstances would we use a multi-line label and not a text area? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
RonShortt Posted August 8, 2021 Author Share Posted August 8, 2021 It is an area of the screen where I am writing output from the program on an ongoing basis as the program runs. I will take a closer look at the text area widget this evening and see if I can use that to accomplish the same thing. Quote Link to comment Share on other sites More sharing options...
Josh Posted August 8, 2021 Share Posted August 8, 2021 In your usage you describe I would definitely use the TextArea widget. It will display scroll bars when the text becomes bigger than the area of the widget. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
RonShortt Posted August 9, 2021 Author Share Posted August 9, 2021 It's funny but I had misread the TextArea widget and thought it was an input field so it does do exactly what I need. Thanks for the advice. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.