Different colours in one string

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

zarroba
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Tue Jul 11, 2006 12:54

Postby zarroba » Wed Jun 20, 2007 10:14

Yesterday I managed to keep the colour trigger to appear when in an editbox or in a multiline editbox. I have just change the handleCharRight and handleCharLeft.

handleCharRight:

Code: Select all

String text = this->getText();
        int triggerSize = this->getFont()->getColourTrigger().size()+8;
        int jump = 1;
        int lastChar = text.size();
        size_t pos = text.rfind(this->getFont()->getColourTrigger());

        while (pos > d_caratPos)
        {
                if (pos == d_caratPos+1)
                        jump = triggerSize+1;

                if (pos == text.size()-triggerSize)
                        lastChar = text.size()-triggerSize-1;

                pos = text.rfind(this->getFont()->getColourTrigger(), pos-triggerSize);
        }

        if (d_caratPos < lastChar)
        {
                setCaratIndex(d_caratPos + jump);
        }

        if (sysKeys & Shift)
        {
                setSelection(d_caratPos, d_dragAnchorIdx);
        }
        else
        {
                clearSelection();
        }


handleCharLeft:

Code: Select all

        String text = this->getText();
        int triggerSize = this->getFont()->getColourTrigger().size()+8;
        int jump = 1;
        int firstChar = 0;
        size_t pos = text.find_first_of(this->getFont()->getColourTrigger());

        while (pos < d_caratPos)
        {
                if (pos == d_caratPos-triggerSize)
                        jump = triggerSize+1;

                if (pos == 0)
                        firstChar = triggerSize;

                pos = text.find_first_of(this->getFont()->getColourTrigger(), pos+triggerSize);
        }

        if (d_caratPos > firstChar)
        {
                setCaratIndex(d_caratPos - jump);
        }

        if (sysKeys & Shift)
        {
                setSelection(d_caratPos, d_dragAnchorIdx);
        }
        else
        {
                clearSelection();
        }

Change this in both CEGUIEditbox.cpp and MultiLineEditbox.cpp.
I have to change also handleWordLeft and handleWordRight as well as the method that is called when I click with the mouse in the widget.
I'm having some problems realising how to different styles in a text. Is it easier to do it in CEGUIFont or to create a new widget? if I do it in CEGUIFont I'll have to have a glyph for each style right?

thanks

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Fri Jul 06, 2007 11:56

How far is this now ? zarroba, have you already patched the other functions you say you still need to patch ?

Edit1: Ok I applied everything and it works like charm, good job ! The only thing are still the editbox types, but the question is how one wants to handle it. I personally think it would be the less confusing if the editboxes don't translate the color code but just show it. I'll look into this and if I have succes I'll send a patch.

Edit2: Oh well .. I looked into this and it seems too hard work in the library-side. I do this in the application-side: when loading a window, I check for (multiline)editboxes, if I find some, I just give them the other font that has the colourtrigger disabled.

zarroba
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Tue Jul 11, 2006 12:54

Postby zarroba » Sun Jul 08, 2007 17:11

I've stopped the development of this for now. I've too reached the conclusion it will be hard to do this and I'll actually create a new widget for this. I was doing it because I want to do a script editor in cegui and it was a way of doing the highlight of keywords. I have scheduled this to august and what I'll try to do is a widget that will render the text with different styles (for the keywords). It will not use tags like this example. I'll post the results then.

User avatar
ldb
Quite a regular
Quite a regular
Posts: 54
Joined: Sat Mar 24, 2007 13:39
Location: Bloomington, IL
Contact:

Postby ldb » Sun Jul 08, 2007 17:33

zarroba wrote:I've stopped the development of this for now. I've too reached the conclusion it will be hard to do this and I'll actually create a new widget for this. I was doing it because I want to do a script editor in cegui and it was a way of doing the highlight of keywords. I have scheduled this to august and what I'll try to do is a widget that will render the text with different styles (for the keywords). It will not use tags like this example. I'll post the results then.


yeah, this is where i pretty much stand on the issue as well.
No matter where you go, there you are.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 1 guest