5. More than a Text Editor

5.1. Indenting
5.2. Auto tag closing
5.3. Spell checker
5.4. Function reference
5.5. HTML
5.5.1. Special find and replace features
5.5.2. Thumbnail generation
5.6. Customizing the Quick bar
5.7. Custom menu
5.7.1. Adding a custom menu dialog
5.7.2. Adding a custom replace dialog
5.8. External programs, filters
5.8.1. Customizing browsers
5.8.2. Customizing Commands menu
5.8.3. Customizing Ouputbox menu

5.1. Indenting

To indent large sections of text, simply highlight the section and choose EditShift Right (Ctrl-.). To remove an indentation, choose EditShift Left (Ctrl-,). There are corresponding buttons in the tool bar for these menu options (see later in this text).

By default, Bluefish will use tabs for indenting, but can be configured to use spaces if you have Use spaces to indent, not tabs selected in the Editor preferences panel. The number of spaces used is the same as the Tab width option in the same preferences panel.

Here's an extract of Dante's work indented with the Shift Right button in the main tool bar:

Figure III.67. Indenting part of a text

A screen shot of a text indented with the shift right button

5.2. Auto tag closing

By default, Bluefish will automatically produce closing tags for HTML and XML documents. For example, if you type <p> within an HTML document, bluefish will produce </p>. So, as soon as you finish typing a non-empty HTML tag, meaning the tag is supposed to have a closing tag, Bluefish will help you out and close the tag automatically. This feature can be turned off by unchecking the DocumentAuto Close HTML Tags (Ctrl-T) menu option.

Bluefish has two modes for tag closing, an XML mode and an HTML mode. In XML mode, Bluefish will add a closing tag to any tag that is not closed itself with />. In HTML mode, Bluefish excludes all known tags that do not need a closing tag, such as <br> and <img>.

Bluefish will choose the mode based on the file type of the document. In the filetype preferences panel, the default mode for each file type can be set. See Section 6.10, “Modifying file types” for more info.

5.3. Spell checker

Figure III.68. Bluefish Spell Checker

A screen shot of the Bluefish 1.0 spell checker

Bluefish uses aspell for spell checking. If the aspell libraries are not installed on your system, then the spell checking feature will not be available. At the aspell web site you can also download dictionaries for many different languages.

To launch the spell checker, select DocumentCheck Spelling... or click on the ABC button on the main tool bar. The spell checker will launch in a separate window, which you can keep open as you edit files.

You have the option to check a whole document or just a selection, to use a personal or a session dictionary, and to choose the language depending on the installed dictionaries.

Click on Spell Check to start spell checking the current document.

You may want to set a default dictionary by first choosing the language in the Language pop up menu, then clicking on Set default.

Key words for different languages can be ignored using filters. Currently, the only filter is for HTML. If you want to help write more filters, join the mailing list.

5.4. Function reference

The function reference browser contains reference information for different programming and markup languages. Currently, Bluefish comes with a PHP reference, a CSS 2.0 reference, an HTML reference, and a Python reference. The functions are grouped, depending on the language, by type, module, object, etc.

The function reference browser will display an info window on the bottom by checking the Show info window check box. In this window, information about the currently selected item is shown. The type of information shown can be configured in the right-click context menu (see Info Type later in this text).

In the reference browser's contextual menu, you can simply insert the text for the selected item by choosing Insert. Or, you can get a little help using Dialog, which launches a dialog window containing fields for the currently selected item's attributes or parameters. For a summary of an item's usage, choose Info. The contextual menu is also accessible on a group of functions and at the top level of a reference.

Figure III.69. The reference browser contextual menu

A screen shot of the reference browser contextual menu

The Options menu accessible via the contextual menu offers three actions:

Figure III.70. The reference browser options menu

A screen shot of the reference browser options menu
  • Rescan reference files in case you have customized one of them, so that the new items be available.

  • Left doubleclick action, which can be:

    • Insert to insert the function in the document for latter parametrizing if needed

    • Dialog to insert the function in the document while filling in the parameters in a dialog window:

      Figure III.71. A function reference dialog window

      A screen shot of a function reference dialog window
    • Info to display a window with all available info about the function:

      Figure III.72. Info available for a function

      A screen shot of all info available for a function
  • Info Type: this is where you can customize what appears in the info window. It can be:

    • the function Description (this is the default)

    • the Attributes/Parameters of the function

    • some Notes about the function

5.5. HTML

HTML is obviously the most supported language in Bluefish. There is a special HTML tool bar with many dialogs, and two menus to work with tags:

  • the Tags menu:

    Figure III.73. The HTML Tags menu

    A screen shot of the HTML tags menu
  • the Dialogs menu:

    Figure III.74. The HTML Dialogs menu

    A screen shot of the HTML dialogs menu

The preferences have several settings on HTML style under HTML.

The HTML tool bar has two types of buttons. You can recognise each type by the tool tip if you move the mouse over the button:

  • First there are buttons that will open a dialog for some HTML tag. These buttons have a tool tip that ends with three dots.

    Figure III.75. An HTML button with a three-dotted tool tip

    A screen shot of an HTML three-dotted tool tip
  • Second, there are buttons that will directly insert text, these buttons do not have the dots in the tool tip.

    Figure III.76. A simple HTML tool tip button

    A screen shot of a simple HTML tool tip

If you want to add an HTML tag around some block of text, select the block of text, use the HTML tool bar or the Tags or Dialogs menu to insert the tag. The opening tag will be inserted before the selected block, the closing tag after the selected block.

An existing tag can be edited by right-clicking the tag, and select Edit tag in the context menu. You can also place the cursor in the tag and use DialogsEdit tag under cursor... (F3). Not all tags, however, have a dialog, so this is not always possible. Colors in the style #RRGGBB can also be edited from the right-click context menu.

In the reference browser on the left panel there is an HTML reference available. All possible attributes and valid values can be found in this reference. See Section 5.4, “Function reference” for more info.

5.5.1. Special find and replace features

There are several special search and replace actions in the menu EditReplace special. These can be used to convert special characters (like < and &), or ISO characters to their HTML entities, as well as to change the letters case.

Figure III.77. The Replace special menu

A screen shot of the Replace special menu

In all cases, when you want to replace some part of the text, you should first select the part to replace, then use the appropriated menu item.

5.5.2. Thumbnail generation

Bluefish can automatically generate thumbnails for images. A thumbnail is a small image, with a link to the larger image. Bluefish will create the small image based on your settings, and insert a <img> tag in the file, and a <a> tag linking the original. The thumbnails are created in the same directory as the original sources.

The formats used for thumbnails may be png or jpg format. By default, the format used for thumbnails is png. You can change it in the Images panel of Preferences. For jpg images, the thumbnail extension is jpeg.

There are actually two thumbnail dialogs in Bluefish:

  • an Insert thumbnail dialog,accessible from the DialogsGeneralInsert Thumbnail... (Shift-Alt-N) or from the Standard bar of the HTML toolbar.

    Figure III.78. The Insert thumbnail icon

    A screen shot of the insert thumbnail icon
  • a Multi thumbnail dialog, only accessible from the Standard bar of the HTML toolbar.

    Figure III.79. The Multi thumbnail icon

    A screen shot of the multi thumbnail icon

The Insert thumbnail dialog is very straightforward. You select the image file, provide some <img> tag attributes, choose the scaling, and press OK. The scaling factor is chosen by moving the slider directly under the image. The resulting image is previewed in the preview frame. Bluefish will create the thumbnail with extension _thumbnail.png or _thumbnail.jpeg (depending of the settings for images in the preferences).

Figure III.80. The Insert thumbnail dialog

A screen shot of the insert thumbnail dialog
[Tip]

If the source image is not accessible, change webimage to image in the Select File window loaded after clicking on browse for choosing an image. This way you can choose whichever format you want for the original sources. Another way to do it is to change the definition of webimage (see Section 6.10, “Modifying file types”).

If that does not solve the problem, it is likely that the type of images you want to load is not defined yet in preferences. In this case, change the definition of image as explained in Section 6.10, “Modifying file types”.

As last resource, if you don't want to change the generic file types, you may choose All files in the pop up menu at the bottom of the Select File window.

The code generated for a png image and a png thumbnail looks like this:

<a href="/Users/michga/Desktop/343-4351_IMG_2.png">
<img src="/Users/michga/Desktop/343-4351_IMG_2_thumbnail.png" 
width="89" height="134" border="0" name="Gamboling" 
alt="Gamboling in the meadow" align="middle"></a>

and for a jpg image and jpg thumbnail:

<a href="/Users/michga/Desktop/343-4351_IMG_2.JPG">
<img src="/Users/michga/Desktop/343-4351_IMG_2_thumbnail.jpeg" 
width="89" height="134" border="0" name="Gamboling" 
alt="Gamboling in the meadow" align="middle"></a>
[Note]

You can perfectly mix jpg images with png thumbnails or the other way around.

If the html file exists beforehand, the paths to image and thumbnail are inserted relative to the location of the html file. On the contrary, if the html file does not exist beforehand, the full paths to the image and thumbnail are inserted in the code.

In the multi thumbnail dialog, you first choose the scaling method, then you set the corresponding width and/or height parameters. Finally, you may want to adjust the HTML code to be inserted for each image.

Scaling can be based on a fixed ratio, a fixed width, a fixed height, or a fixed width and fixed height (this last option does not keep the original aspect ratio!).

In the HTML code for each image, you can use several placeholders, such as:

  • %r for the original filename

  • %t for the thumbnail filename

  • %w for the original width

  • %h for the original height

  • %x for the thumbnail width

  • %y for the thumbnail height

  • %b for the original file size (in bytes)

The default string is:

<a href="%r"><img src="%t" width="%x" height="%y" border="0"></a>

After you have set up the scaling method and parameters, as well as the HTML code, you can select multiple images. Bluefish will create the thumbnails and insert the code.

Here is an example of two thumbnails created with a non nul border width and middle-aligned, with a fixed height and width, disregarding the aspect ratio.

The Multi thumbnail window is the following:

Figure III.81. The Multi thumbnail dialog

A screen shot of the multi thumbnail dialog

And the generated code is:

<a href="/Users/michga/Desktop/tot/343-4351_IMG_2.png">
<img src="tot/343-4351_IMG_2_thumbnail.png" width="50" 
height="50" border="5" align="middle"></a>
<a href="/Users/michga/Desktop/tot/343-4352_IMG_2.png">
<img src="tot/343-4352_IMG_2_thumbnail.png" width="50"
height="50" border="5" align="middle"></a>
[Note]

Full pathnames are always used to reference original image sources. The paths to thumbnails are relative to the html file path if the html file already exists, while they are inserted as full paths when the html file does not exist.

Below is a full procedure to quickly generate thumbnails from a directory of image files. This example is purposedly made with deprecated tags, so that you have an idea of what can be made with the variables. Feel free to adjust it when using CSS style sheets.

Procedure III.4. Generating a photos album with multi thumbnails

  1. Put the image files in a folder of their own

  2. Open a new file in bluefish, click on the Multi thumbnail... icon in the Standard bar tab of the html tool bar.

  3. Enter the scaling percentage in the Scaling (%) field

  4. Change the html code as follows:

    <tr><td><a href="%r">
    <img src="%t" 
    width="%x" height="%y" border="0"></a>
    </td>
    </tr>
    <tr><td>Original: %w x %h</td></tr>

    and click OK.

  5. Choose the folder containing the images from the Select files for thumbnail creation window, click Ctrl-A to select all files, then click OK. The code generated by Bluefish will look like the following:

    <tr><td><a href="/Users/michga/Desktop/photos/343-4344_IMG.JPG">
    <img src="/Users/michga/Desktop/photos/343-4344_IMG_thumbnail.png" 
    width="80" height="53" border="0"></a>
    </td>
    </tr>
    <tr><td>Original: 1600 x 1065</td></tr>
    <tr><td><a href="/Users/michga/Desktop/photos/343-4347_IMG.JPG">
    <img src="/Users/michga/Desktop/photos/343-4347_IMG_thumbnail.png" 
    width="80" height="53" border="0"></a>
    </td>
    </tr>
    <tr><td>Original: 1600 x 1065</td></tr>
  6. Use Ctrl-A to select the file's contents and click on the Table icon located in the Tables tab of the HTML tool bar to embed the code into table tags.

    Figure III.82. The Table icon in the html tool bar

    A screen shot of the table icon in the html tool bar
  7. Save the file wherever you want.

If you want to add the file name and the file size in bytes, use this code:

<tr><td><a href="%r">
<img src="%t" width="%x" height="%y" border="0"></a>
</td>
</tr>
<tr><td>%r:  %w x %h (%b bytes)</td></tr>

5.6. Customizing the Quick bar

The Quick bar is a user defined tool bar. All HTML tool bar buttons can be added to the Quick bar by simply right-clicking the button and selecting Add to quickbar.

Figure III.83. Adding an element to the Quick bar

A screen shot showing how to add an element to the Quick bar

And automagically you will see the element in the Quick bar:

Figure III.84. The added element in the Quick bar

A screen shot showing the added element in the Quick bar

Note that you cannot add a pop up menu. Thus, if the item you want to add is inside a pop up menu (as is the code tag located in the Context formatting pop up menu of the Fonts tool bar), you have to first click on the pop up menu to display its contents, then to right click on the desired element to insert it in the Quick bar.

Figure III.85. Adding a pop up menu element to the Quick bar

A screen shot showing how to add a pop up element to the Quick bar

If you want to remove items from the Quick bar, right-click them and select Remove from Quick bar.

Figure III.86. Removing an element from the Quick bar

A screen shot showing how to remove an element from the Quick bar

You can also change the location of an element in the Quick bar. To do so, right-click the element and select Shift left or Shift Right as desired. The element will be moved to the left or to the right of its neighborough. Notice that this is not a drag and drop action; you may have to repeat the process if you want to move the element farther.

Figure III.87. Moving an element within the Quick bar

A screen shot showing how to move an element within the Quick bar

5.7. Custom menu

To customize items in the Custom menu tool bar, you will use the Custom menu element:

Figure III.88. Accessing the custom menu

A screen shot of the default custom menu's access

The Custom menuEdit custom menu... leads to the Custom Menu Editor. The Load new item allows you to load a new menu in case you have directly changed the custom_menu file located in the .bluefish directory within your HOME directory, while Reset item allows you to return to the default custom menu under the same circumstances.

The custom_menu file is created upon install Bluefish and corresponds to some default entries, the ones you can see in the Custom menu tool bar. These will give you an idea what can be done with the custom menu.

The custom menu operates only on elements of the Custom menu tool bar, and allows you to:

  • add "often used" items to an existing menu

  • search and replace patterns to the Replace menu

  • create new menus

The Custom Menu Editor is the place where you make all changes to the custom menu. The location for entries in the custom menu is defined by their menu path in the Custom Menu Editor:

Figure III.89. The Custom Menu Editor

A screen shot of the custom menu editor

It has four parts:

  • The top one with all action buttons:

    • Add which adds new menu entries, once all necessary fields have been filled in

    • Apply which applies changes to an existing menu entry, once it has been edited

    • Delete which deletes the menu entry currently selected in the Menu path list

    • Close which discards changes

    • Save which saves the changes and exit the editor

  • The Menu Path field below the buttons, to enter either an existing or a new menu path

  • The Menu path list on the left side, which lists existing menu paths. A menu path looks like /Main menu/submenu/item or /Main menu/item. Here's an extract of the default custom menu paths:

    Figure III.90. Extract of the default custom menu path

    A screen shot showing an extract of the default custom menu path

  • A custom part on the right side, whose contents changes depending of the type of menu. There are two types of items in the Custom Menu Editor:

    • the Custom dialog, which will insert a string, optionally based on values asked in a dialog

    • the Custom Find and Replace, which will run a replace, also optionally based on values asked in a dialog. Here's how the Custom Replace dialog looks like:

      Figure III.91. The Custom Replace Dialog

      A screen shot of the custom replace dialog

5.7.1. Adding a custom menu dialog

The most simple custom dialog item has a menupath, for example /MySite/author, and a Formatstring before, for example written by Olivier. If you add this item, you can add this string by selecting the menu item.

Procedure III.5. Adding a custom menu based on custom dialog

  1. Choose Custom menuEdit custom menu... in the custom menu tool bar.

  2. Enter /MySite/author in the Menu Path field of the Custom Menu editor.

  3. Enter written by Olivier in the Formatstring Before field located on the right.

  4. Click on the Add button at the top.

    Notice that upon adding the new entry, it is listed at the bottom of the Menu path list:

    Figure III.92. A new custom entry in the Menu path list

    A screen shot of a new custom entry in the Menu path list
  5. Click on the Save button. This will add the menu to the Custom menu tool bar:

    Figure III.93. A new menu in the custom menu tool bar

    A screen shot of a new menu in the custom menu tool bar

Note that the new menu is placed at the right end of the custom menu tool bar. When closing Bluefish and relaunching it, it will be placed in alphabetical order, except that the Replace menu will always be at the far right side.

In another example, you have a string you often need to set before and after some block of text, for example <div class="MyClass">YourBlockOfText</div>. To do it:

  1. Open the Custom Menu Editor

  2. Enter /MySite/div with class in the Menu Path field

  3. Enter <div class="MyClass"> in the Formatstring Before field

  4. Enter </div> in the Formatstring After field

  5. Click on Add, then on Save. The item will appear in the menu.

If you select some text:

Figure III.94. A block of selected text before activating the menu

A screen shot of a block of selected text before activating the menu

And activate this menu item, the first bit of text is now added before the selection, and the second bit after the selection:

Figure III.95. A block of text after activating the menu

A screen shot of a block of text after activating the menu

Suppose you want to improve this last example. You have both MyClass1 and MyClass2 and want to be able to choose the desired class when activating the menu. Here's how to do it:

  1. Open the Custom Menu Editor

  2. Browse the Menu path list to retrieve the /MySite/class with div entry and click on it to make appear its components in the Menu Path and Custom Dialog fields

  3. Click on the top arrow of the Number of Variables pop up menu to get 1 in the field. As you see a Variables entry appears where you can enter the name for variable %0. As name we enter MyClass number

  4. Now change the FormatString Before field to take this new variable into account, as following: <div class="MyClass%0">

  5. Click on Apply so that your changes will be taken in account, and click on Save to update the menu.

If you now activate this menu after having selected a block of text, you will be presented with a new dialog asking you for the value of MyClass number:

Figure III.96. The new div with class dialog

A screen shot of the new div with class dialog

After entering the desired value, the same process as before will occur, using the value you provided. Here we have entered 1 as value:

Figure III.97. The block of text after entering the value

A screen shot of the block of text after entering the value
[Tip]

You can use the Return and Tab keys to format the output.

Any variable can be used any times you want in the dialog.

5.7.2. Adding a custom replace dialog

Find and replace items are no different. The dialog has some more options, each of these options corresponds to the regular Replace dialog. Again you can use variables like %0, %1 etc. to make a certain menu item more flexible.

Say you want to add title tags to a selection in a HTML page so that the user agent could render it either as a tool tip or as spoken words. To ease the discussion we will work on the following snippet of code:

<ul>
<li><a href="progsys01.html">Process scheduling</a> - 26/10/2002</li>
<li><a href="progsys02.html">Fork and Wait</a> - 02/11/2002</li>
</ul>

We will transform it into the following one:

<ul>
<li><a href="progsys01.html" title="blah Process scheduling">Process scheduling</a> \
- 26/10/2002</li>
<li><a href="progsys02.html" title="blah Fork and Wait">Fork and Wait</a> \
- 02/11/2002</li>
</ul>

where blah is any text you want.

The initial rendering:

Figure III.98. The HTML page before the transformation

A screen shot of the HTML page before the transformation

will be transformed as is:

Figure III.99. The HTML page after the transformation

A screen shot of the HTML page after the transformation

To do this, we need to express the <a href="yoururl">yourstring</a> part of the initial snippet of code as a Perl regular expression (see Section 4.5.3, “Find and Replace Using Regular Expressions” for full details):

  • a href=" will be expressed as is and embedded into parentheses to retrieve it as \0 variable.

  • yoururl will be expressed as ([^"]+) to match one or more non double quote characters and retrieve it as \1 variable.

  • The second double quote will be expressed as is and embedded into parentheses to retrieve it as \2 variable.

  • The second > sign will be expressed as is and embedded into parentheses to retrieve it as \3 variable.

  • yourstring will be expressed as ([^>]+) to match one or more non > characters and retrieve it as \4 variable.

  • </a> will be expressed as is and embedded into parentheses to retrieve it as \5 variable.

Thus, the search string will be: (<a href=")([^"]+)(")(>)([^>]+)(</a>)

The replace string should be of the form: <a href="yoururl" title="yourvariablestring yourstring">yourstring</a>

Expressed as a regular Perl replacement expression, it will be as simple as: \0\1\2 title=\2%0 \4\2\3\4\5 where %0 will match yourvariablestring, that is the value entered in the Title field of the Replace dialog at activating time.

Procedure III.6. Adding a custom menu based on replace dialog

  1. Choose Custom menuEdit custom menu... in the custom menu tool bar.

  2. Browse the Menu path list to retrieve the /Replace/Convert in Selection/<td> to <th> and click on it to make appear its components in the Menu Path and Custom Replace fields.

  3. Change the Menu Path to /Replace/Anchor/Add Title.

  4. Click on the top arrow of the Number of Variables pop up menu to get 1 in the field. Enter Title in the %0 Variables field.

  5. Change the Matching pop up menu to perl regular expressions.

  6. Change the Search Pattern field like this:

    (<a href=")([^"]+)(")(>)([^>]+)(</a>)
  7. Change the Replace String field like this:

    \0\1\2 title=\2%0 \4\2\3\4\5
  8. Click on the Add button.

    The Custom replace dialog should have the following appearance:

    Figure III.100. The custom menu replace dialog filled in

    A screen shot of the custom menu replace dialog filled in
  9. Click on the Save button.

To use the new menu item, select the lines to be changed in the HTML file and activate Replace/Anchor/Add Title in the custom menu bar. Fill in the dialog as follows:

Figure III.101. The Add Title dialog

A screen shot of the Add Title dialog

Click OK to proceed.

5.8. External programs, filters

The External menu provides a quick access to external default or user-added programs and text filters. It is divided into three parts by default (see Section 6, “Customising Bluefish” for layout change):

  • The Outputbox submenu for text filters. Its name is derived from the output box shown at the bottom of the document window, where you can see the output of the process, when activating it.

  • The Commands submenu for external programs.

  • All other items are browsers. They are launched as subprocesses, hence you need to detach them to avoid freezing bluefish until the external program quits.

[Note]

Typically all programs and filters apply to the current document. Nevertheless it is possible to invoke a program without applying it to the current document. On the contrary, it is not possible to apply text filters to anything but the current document.

Figure III.102. Bluefish External Menu

A screen shot of the Bluefish 1.0 external menu

Customization of the External menu is performed in different parts of the Edit Preferences dialog:

  • Items in the Outputbox submenu in the Output parsers tab.

  • Items in the Commands submenu in the Utilities and filters part at the bottom of the External programs tab.

  • Top level items in the Browsers part at the top of the External programs tab.

5.8.1. Customizing browsers

The Browsers panel in Preferences shows the items in the same order as in the External menu:

Figure III.103. The Browsers panel in Preferences

A screen shot of the Bluefish 1.0 Browsers panel in the Edit Preferences dialog
[Note]

The first line in the panel will be the browser selected when clicking on the View in browser button in the main tool bar.

If you want to change the order of the browsers, apply the following steps:

Procedure III.7. Changing the order of browsers items

  1. Click on the Preferences... icon in the main tool bar to access the Edit preferences panel.

  2. Click on the External programs tab to display the Browsers panel.

  3. Click near the left border of the browser's line you want to move. The whole browser's line will be highlighted:

    Figure III.104. Selecting the browser's line to be moved

    A screen shot showing how to select the browser's line to be moved
  4. While maintaining the click, drag the selected line over another line, until you reach the place you want, so that the selected line covers entirely the latter one. The cursor will change its appearance and the dragged line will be shown as a framed line:

    Figure III.105. Dragging the browser's line

    A screen shot showing the line's dragging
    [Note]

    To drag a line to the end of the list, drag it until a thin line appears below the last item:

    Figure III.106. Dragging the browser's line to the bottom

    A screen shot showing how to drag the line to the bottom of the list
    [Tip]

    If you change your mind, drag the line over its original place and release the mouse button. There will be no change.

  5. Release the mouse button to drop the line at the desired place.

  6. Click on the Apply button to save the change if you plan to make further changes in the panel, otherwise click on the OK button to save the change and close the Edit preferences panel.

If you want to customize one of the browsers supplied by default, use the following procedure:

Procedure III.8. Customizing an existent browser

  1. Click on the Preferences... icon in the main tool bar to access the Edit preferences panel.

  2. Click on the External programs tab to display the Browsers panel.

  3. Click on the Command region of the browser's line you want to change. The line will be hightlighted.

  4. Double-click on the same location to allow editing. The line will be framed.

  5. Make the desired change

  6. Click on the OK button to save and close the panel.

To add a new browser, proceed as follows:

Procedure III.9. Adding a new browser

  1. Click on the Preferences... icon in the main tool bar to access the Edit preferences panel.

  2. Click on the External programs tab to display the Browsers panel.

  3. Click on the Add button. 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 External menu.

  5. Double-click in the Command zone and enter the command followed by the & sign to detach it from the main bluefish process, for example:

    amaya %s &

  6. Click on the OK button to save and close the panel.

To delete a browser, just click on the Delete button.

Though nothing impedes you to put any command (not necessary a browser) in the panel for quick access, you may want to avoid to put it at the top range, since it will be somewhat strange to click on View in browser to launch abs for example.

5.8.2. Customizing Commands menu

To add items to the ExternalCommands submenu, you use the External programs tab of the Edit Preferences panel:

Figure III.107. Utilities and Filters panel in Preferences

A screen shot of the Bluefish 1.0 Utilities and Filters panel in Preferences

You add, modify, delete, move commands or text filters the same way as described in Section 5.8.1, “Customizing browsers”.

Bluefish will apply the supplied command on the current document, while representing the document as it is before the command is applied by %s and the document after the command has been applied by %f. Usage of the %i parameter is not implemented yet. You should embed those parameters into simple quotes to prevent special characters to be interpreted by the shell.

Usage of the parameters depends on the command:

  • If the command does not operate on the file, as xterm, you just supply it as you would in an xterm, detaching it to avoid bluefish freezing with:

    xterm &

  • If the command does operate on the file, but not on the file's contents, as chmod, you supply it as you would in an xterm, using %s as a reference to the current document:

    chmod +x '%s'

  • If the command operates on the standard input device by default, as tidy, you will have to redirect the document's contents, i.e. %s, with cat for example, to the standard output device, pipe the result so that it will be used as standard input device for the command, then redirect the result of the command to the document, i.e. %f, as in:

    cat '%s' | tidy 'someoptions' > '%f'

  • If the command operates on file's contents, as sed, you should use input, i.e. %s and output, i.e. %f redirection to feed the command with the right parameters, as in:

    sed -e 'somesedcommand' < '%s' > '%f'

As those parameters are used internally to create temporary files, you cannot use them to modify the name of the final document for example. But you can redirect the standard output to a named file, if you do not want to override the current document, as in:

sed -e 'somesedcommand' < '%s' 1 > 'namedfile'

Here is an example to get rid of hard-coded /usr in a source file:

Procedure III.10. Adding a Commands menu item

  1. Click on the Preferences... icon in the main tool bar to access the Edit preferences panel.

  2. Click on the External programs tab to display the Utilities and filters panel.

  3. Click on the Add button. 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 External menu.

  5. Double-click in the Command zone and enter:

    sed -e 's|\/usr|${PREFIX}|g' < '%s' > '%f'.

    [Note]

    We need to escape the slash in /usr with a backslash to avoid interpretation by the shell.

  6. Click on the OK button to save and close the panel.

5.8.3. Customizing Ouputbox menu

Items within the ExternalOutputbox submenu allow for programs to give feedback by opening an output box at the bottom of Bluefish's main window.

Here is an example showing the output box after using the ExternalOutputboxtidy HTML validator item on an html file with an on purpose error:

Figure III.108. The tidy output box in Bluefish 1.0

A screen shot of the tidy output box in bluefish 1.0

The contents of the resulting output box are based upon scanning the output of the supplied command, as it appears in an xterm, with a given regular expression and filling in the various fields of the output box with the desired parts of that regular expression. The Output parsers tab of the Edit preferences panel provides you with a model to do that:

Figure III.109. The Output parsers tab in Preferences panel

A screen shot of the output parsers tab in preferences panel

The Outputbox panel comprises 7 fields:

  • The Name field, a character string which will appear as the item in the Outputbox menu.

  • The Pattern field, a Perl regular expression which describes the command output, so that some of its parts could be used in the following fields.

    Let's use an example: say you have a ruby script named foo.rb with the following line in it:

    put Hello Word

    When executing ruby -d foo.rb in an xterm, the output is:

    Exception `NoMethodError' at foo.rb:1 - undefined method `put' for main:Object
    foo.rb:1: undefined method `put' for main:Object (NoMethodError)

    The second line can be parsed with the following Perl regular expression:

    ([a-zA-Z0-9/_.-]+):([0-9]+):(.*)

    The first part embedded into parentheses will match the script name, i.e. foo.rb; the second part will match the line, i.e. 1: the third part will match the remaining. See Section 4.5.3, “Find and Replace Using Regular Expressions” for some explanation on using regular expressions within bluefish.

  • The File # field, a part number matching the filename in the Perl regular expression given in the Pattern field. Note that the first part is numbered 1, the second 2, etc. If you do not want that the part be shown, put -1 in it.

  • The Line #, a part number matching the line number in the regular expression, here it will be 2, as same rules apply as in the Filename # field.

  • The Output # field, a part number matching the desired part in the regular expression, typically the remaining of the line, here it will be the third and last part. Again, same rules apply as in the Filename # field.

  • The Command field, the command to execute on the current document, internally named %s. Here it will be: ruby -d '%s'. Notice that you should embed the reference to the current document, if any, within parentheses to avoid interpretation at run time.

  • The Show all output check box, which can be checked to show all output not matching the Perl regular expression. Here it is not needed, since the regular expression matches all output.

You add, modify, delete, move output boxes the same way as described in Section 5.8.1, “Customizing browsers”.

Procedure III.11. Adding an Outputbox menu item

  1. Execute the desired command in an xterm with some error either in the command or in the file which it is applied on, in order to know how the errors are outputting.

  2. Build a Perl regular expression based on the output, so that the filename, the line number and the error message be retrieved.

  3. Click on the Preferences... icon in the main tool bar to access the Edit preferences panel.

  4. Click on the Output parsers tab to display the Outputbox panel.

  5. Click on the Add button. A new line will be shown, with an Untitled label.

  6. Click "Add" to add a new item.

  7. Double-click on the Name field to give the command a name.

  8. Double-click on the Pattern field and fill it in with the Perl regular expression you have built previously.

  9. Double-click on the File # field and give the number for the subpattern matching the filename (-1 for none).

  10. Double-click on the Line # field and give the number for the subpattern matching the line number (-1 for none).

  11. Double-click on the Output # field and give the number for the subpattern matching the actual error message (-1 for none).

  12. Double-click on the Command field and enter the command to execute in the form command options '%s', %s being the current filename.

  13. Toggle the "Show all output" check box to show output NOT matching the regular expression, if needed.

[Note]

Of course, it is also possible to add these items by editing the file named ~/.bluefish/rcfile_v2 found in the user's home directory. The fields are delimited by colons and correspond to those found in the GUI.