News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

How to change the selection color of XML file?

Started by photon3108, September 29, 2010, 04:43:46 AM

Previous topic - Next topic

photon3108

XML doesn't have selection highlighting.

How to change the selection color of XML file?

Thanks.

seb_seb0

You have 2 solutions:

   1 - if the file is already open, select the menu "Edit" -> "Highlight Mode" -> "XML"

   2 - for a permanent fix: go in menu "Settings" -> "Editor"
        In the dialog box, choose "Syntax Highlighting" button on the left toolbar
        In the ComboBox, choose the language "XML"
        Click on the button "Filemasks" and type: "*.xml,*.xsl,*.xrc," in the dialog box
        Click OK to close the text box
        Click OK to close the dialog box
        Quit Codeblocks and restart it (to save the new settings)

It works perfectly for me.
Best regards,

Sebastien

photon3108

Thanks for your reply.

In the Syntax Highlighting, C/C++ has two members, "Selection" and "Active line".

How can I find these two members in the XML Syntax Highlighting?

seb_seb0

Hello,

I have misunderstood your question. I thought you were speaking about "syntax" highlighting.

For coming back at your problem, I believe the only way is to write a new XML Lexer for the Scintilla component.
See here for a starting point : http://wiki.codeblocks.org/index.php?title=Creating_a_custom_lexer_for_Code::Blocks_editor

I hope this helps.

Sebastien

Jenna

Edit "share/codeblocks/lexers/lexer_xml.xml" in the install-folder of C:B and add:

                <Style name="Selection"
                        index="-99"
                        bg="192,192,192"/>
                <Style name="Active line"
                        index="-98"
                        bg="255,255,160"/>


After restarting C:B, you should be able to change the colour.

photon3108

Thank you, jens. It works.

But I have another question. If I do that as you said, the color of "Selection" and
"Active line" of plain text will become the same setting of xml.

How can I set the color of plain text or just make the setting only work on xml format,
not plain text or others?

Jenna

You should be able to change it in "Settings -> Editor -> Syntax highlighting -> Syntax highlighting for. -> XML".

photon3108

Yes, it can and I did.

I change the color of "Active line" of XML and the active line of *.xml realy shows the right color.
But sometimes when I open *.txt, the plain text will use the color setting of "Active line" of XML.
And sometimes it doesn't.

If I follow those steps, I can produce this problem.

1. Start Codeblocks.
2. open abc.xml
    ( It shows right color of active line what I setted )
3. open abc.txt
    ( Problem: It uses the color setting of active line of XML, not plain text itself. )
4. Close Codeblocks.
5. Start Codeblocks again.
6. open abc.txt
    ( The same problem. )

Now if I open the page of "Settings -> Editor -> Syntax highlighting -> Syntax highlighting for. -> XML"
and don't do anything just press yes to close this page, the plain text use the default color of active
line, not the color of XML.

I want plain text use plain text's color and XML use XML's color. Something like each language, e.g. XML,
inherit the color from plain text if it wasn't set. Plain text doesn't inherit anyone.

How can I do that?

platform: Fedora 12 + Codeblocks release 10.05 rev 0 ( installed by yum )