[Home]Highlighting In Gedit

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

To manually select syntax-highlighting for a file in gEdit you'll need to select the right "Highlight mode" from the view-menu.

If you want to change the color-scheme for the active highlight mode, open the preferences from the Edit-menu, then chose the syntax highlighting tab.

Highlight style files are in the /usr/share/gtksourceview-1.0/language-specs directory, you'll need root access to edit these files.

1. Highlighting configuration files

Copy ini.lang to hal.lang and modify the first couple of lines so that they read as below.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<language _name="HAL" version="1.0" _section="Others" mimetypes="text/x-hal-file;application/x-hal-file">

Now when you open gEdit and pick a highlighting mode you will see hal in there.

The specific markup is listed in the file named language.dtd in the same directory. Each element corresponds to one set of highlight characteristics. For example

<line-comment _name = "HAL Comment" style= "Comment">
<start-regex>#</start-regex>
</line-comment>

Will pick out the hash mark (#) and use the name = "HAL Comment" style.

While you may only use the element name, you can use an element like "line-comment" more than once with the same name if you wish to have several different highlight types displayed using the same coloration. You can also have more than one "line-comment" with different names and the color picker will allow you to colorize each differently.

2. Highlighting .ngc files

To highlight .ngc files you can simply download the upload:ngc.lang file and copy it to your /usr/share/gtksourceview-1.0/language-specs directory. Note: on Ubuntu 10.04, the version of gtksourceview is 2.0, so you need to copy the file to /usr/share/gtksourceview-2.0/language-specs instead.

use the color picker in gEdit to give your ngc-files some nice colors =)
upload:gedit-syntax.png

3. Adding a text/ngc mime-type

The ngc.lang file is configured to automatically highlight files with the text/ngc mime-type, Ubuntu marks the .ngc-files as text/plain, if follow these instructions the .ngc-files are automatically marked as text/ngc.

from the command-line:

sudo gedit /usr/share/mime/packages/freedesktop.org.xml

add these lines to the document (not at the beginning, but between 2 other <mime-type> elements)

<mime-type type="text/ngc">
<sub-class-of type="text/plain"/>
<comment>ngc document</comment>
<glob pattern="*.ngc"/>
</mime-type>

save the file and exit gEdit.

Rebuild the mime-database, from the command-line:

In 6.06 use:

sudo su
update-mime-database /usr/local/mime
exit

In 8.04, 10.04, 12.04 use:

sudo update-mime-database /usr/share/mime


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited January 14, 2013 12:06 am by Yishin Li (diff)
Search:
Published under a Creative Commons License