Jump to content

Recommended Posts

Posted

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;
}

 

Posted
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.

 

 

  • Like 1
Posted

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.

  • Like 1
Posted

Hmmm, I think the GDI+ (Windows) handles line returns automatically and XRender must not...let me see if there is a way...

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

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.

  • Haha 1
Posted

I think this is a matter of design then.

Under what circumstances would we use a multi-line label and not a text area?

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

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.

Posted

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.

My job is to make tools you love, with the features you want, and performance you can't live without.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...