Writing language definition files: Difference between revisions

From Bluefish Wiki
Jump to navigation Jump to search
No edit summary
Line 21: Line 21:


== The header section ==
== The header section ==
The header section is always loaded for each bflang2 file. The rest of the file is loaded "on demand", so only if it is needed.


<pre>
<pre>
Line 29: Line 30:
</header>
</header>
</pre>
</pre>
=== The mime tag in the header ===
The mime tag specifies for which mime types this definition file is used. There can be multiple mime types specified. Sometimes a file doesn't have a specific mime type, or the mime type is not defined
on many systems. In that case the mime type is often something like text/plain
Bluefish supports a combination of mime type and extension. To detect a file type that
ends on .fake you add
<pre>
<mime type="application/x-fake"/>
<mime type="text/plain?fake"/>
</pre>
=== The option tag in the header ===
The option tag defines an option that is used further on in the language file
<pre>
<option name="allphpfunctions" default="1" description="All php functions" />
</pre>
'''''A special note:''' All language files share one list of option names and their description. So if two or more options have the same name, they will get the same description in Bluefish. If they have a different description inside the file, it is not defined which description is used!!!''

Revision as of 21:06, 11 March 2014

Bluefish language definition files

All syntax highlighting and autocompletion is defined in bluefish language definition files, saved in .bflang2 files. In the source code they can be found in data/bflang/

On Linux they are installed in /usr/share/bluefish/bflang/

If you store a bflang2 file in your bluefish settings directory ~/.bluefish/ it has higher priority than the system wide installed files. So if you are going to change a bflang2 file, just copy it into ~/.bluefish/

The format of the file

The file format is XML.

It starts with a root tag <bflang>:

<bflang name="Shell" version="2.0" >
</bflang>

Inside the root tag there are three sections

The header section

The header section is always loaded for each bflang2 file. The rest of the file is loaded "on demand", so only if it is needed.

<header>
	<mime type="application/x-shellscript"/>
	<option name="show_in_menu" default="1"/>
	<highlight name="value" style="value"  />
</header>

The mime tag in the header

The mime tag specifies for which mime types this definition file is used. There can be multiple mime types specified. Sometimes a file doesn't have a specific mime type, or the mime type is not defined on many systems. In that case the mime type is often something like text/plain Bluefish supports a combination of mime type and extension. To detect a file type that ends on .fake you add

<mime type="application/x-fake"/>
<mime type="text/plain?fake"/>

The option tag in the header

The option tag defines an option that is used further on in the language file

<option name="allphpfunctions" default="1" description="All php functions" />

A special note: All language files share one list of option names and their description. So if two or more options have the same name, they will get the same description in Bluefish. If they have a different description inside the file, it is not defined which description is used!!!