Man 1 ch08s10

From Bluefish Wiki
Jump to navigation Jump to search

Please consider to upgrade to Bluefish 2!

Please consider to edit the Manual 2!

How To edit the Wiki Manual
{{#if:10. Modifying file types|
10. Modifying file types
Prev }}
Chapter VIII. Customising Bluefish

10. Modifying file types

In the Filetypes tab of the Edit preferences panel you can define all file types that should be recognized by bluefish.

The file types consist of:

  1. a label (this label is also used in the file filters, and in the highlighting patterns).
  2. a list of extensions, separated by a colon (:).
  3. the highlighting update characters. Upon a key press of one of these characters, the highlighting engine will refresh the highlighting around the cursor. If this field is empty, any character will force the highlighting engine to refresh. Special characters like the tab and the newline can be entered as \t and \n, the backslash itself is entered as \\.
  4. the icon location for this file type.
  5. whether this file type is editable by Bluefish (whether or not Bluefish should try to open it after a double click).
  6. a regular expression that can be used to detect the file type if a file without extension is loaded.
  7. the auto-tag-closing mode. A value of 0 means that Bluefish should not close XML/HTML tags, a value of 1 means it should close the tags XML style (<br />), a value of 2 means HTML style.

You add, modify, delete, or move file types the same way it is described in external-browsers Section 8.1, “Customizing browsers”.

Example VIII.1. Adding a file type

Let's say you use DocBook xsl stylesheets. Those files are recognized by bluefish as xml files, but they do not appear with the xml icon in the file browser as their extension (.xsl) is not listed in the Extensions field of the Filetypes tab of the Edit preferences panel.

On the other hand, adding them to the xml file type would impede to group them into a stylesheet filter, where they belong from a semantical point of view. And you cannot add them to the provided stylesheet filetype made for css stylesheet, since the highlighting patterns are different.

To add an xsl stylesheet file type, execute the following steps:

  1. Click on the Preferences... icon in the main tool bar to access the Edit preferences panel.
  2. Click on the Filetypes tab to display the Filetypes panel.
  3. Click on the Add button in the Filetypes part. A new line will be shown, with an Untitled label.
  4. Double-click on the label to allow editing, and enter the string you want to appear in the Label field. Here enter xsl stylesheet.
  5. Click in the Extensions zone and enter the extension: .xsl.
  6. Click in the Update chars field of the xml filetype line to copy and paste this field into the corresponding field of the xsl stylesheet filetype line. Once the field is highlighted, use Ctrl+C to copy the field. Click again in the Update chars field of the xsl stylesheet filetype line and use Ctrl+V to paste the field.
  7. For the icon field, you can either use the xml icon path used in the Icon field of the xml filetype line or better create a new icon based on the xml one by changing its colors with the Colormap Rotation filter of gimp, located under the FiltersColorsMap... menu.
    To do it, first copy the xml icon on your Desktop, apply the filter on it, and save it under bluefish_icon_xsl.png in a dedicated folder in your home directory, for example ~/Pictures for Mac users.
    Whichever icon you decided to use, click on the Icon field to enter its path.
  8. Check the Editable box, if it is not already checked.
  9. Copy and paste Content regex field of the xml filetype line into the corresponding field of the xsl stylesheet filetype line.
  10. Set the Auto close tags mode to 1.
  11. Click on the OK button to save and close the panel.

If you want to enter more than one extension in the Extensions field, you should separate them with a colon.

When you define a new filetype, you should also provide new highlighting patterns.

Prev }}
9. Customizing the user interface}}
Home | ToC
 11. Modifying the files filters