Author Topic: How to change the selection color of XML file?  (Read 6295 times)

Offline photon3108

  • Multiple posting newcomer
  • *
  • Posts: 32
How to change the selection color of XML file?
« on: September 29, 2010, 04:43:46 am »
XML doesn't have selection highlighting.

How to change the selection color of XML file?

Thanks.

Offline seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: How to change the selection color of XML file?
« Reply #1 on: September 29, 2010, 09:10:09 pm »
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

Offline photon3108

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: How to change the selection color of XML file?
« Reply #2 on: October 02, 2010, 06:33:27 am »
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?

Offline seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: How to change the selection color of XML file?
« Reply #3 on: October 02, 2010, 02:42:24 pm »
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

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: How to change the selection color of XML file?
« Reply #4 on: October 02, 2010, 06:44:38 pm »
Edit "share/codeblocks/lexers/lexer_xml.xml" in the install-folder of C:B and add:
Code: [Select]
                <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.

Offline photon3108

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: How to change the selection color of XML file?
« Reply #5 on: January 15, 2011, 09:02:54 am »
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?

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: How to change the selection color of XML file?
« Reply #6 on: January 15, 2011, 09:09:01 am »
You should be able to change it in "Settings -> Editor -> Syntax highlighting -> Syntax highlighting for. -> XML".

Offline photon3108

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: How to change the selection color of XML file?
« Reply #7 on: January 15, 2011, 09:44:43 am »
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 )