Macro/Shell Extensions

## Highlighting Information

The user can interrogate the current window to determine the color highlighting used on a particular piece of text. The following functions provide information on the highlighting pattern against which text at a particular position has been matched, its style, color and font attributes (whether the font is supposed to be bold and/or italic).

These macro functions permit macro writers to generate formatted output which allows NEdit highlighting to be reproduced. This is suitable for the generation of HTML or Postscript output, for example.

Note that if any of the functions is used while in Plain mode or while syntax highlighting is off, the behaviour is undefined.

    get_pattern_by_name( pattern_name )

Returns an array containing the pattern attributes for pattern 'pattern_name'. The elements in this array are:

- style -- Highlight style name

If 'pattern_name' is invalid, an empty array is returned.

    get_pattern_at_pos( pos )

Returns an array containing the pattern attributes of the character at position 'pos'. The elements in this array are:

- pattern -- Highlight pattern name
- style -- Highlight style name
- extent -- The length in the text which uses the same highlighting pattern

The 'extent' value is measured from position 'pos' going right/down (forward in the file) only.

If 'pos' is invalid, an empty array is returned.

    get_style_by_name( style_name )

Returns an array containing the style attributes for style 'style_name'. The elements in this array are:

- bold -- '1' if style is bold, '0' otherwise
- italic -- '1' if style is italic, '0' otherwise
- color -- Name of the style's color
- background -- Name of the background color, if any

The colors use the names specified in the color definitions for the style. These will either be names matching those the X server recognises, or RGB (red/green/blue) specifications.

If 'style_name' is invalid, an empty array is returned.

    get_style_at_pos( pos )

Returns an array containing the style attributes of the character at position 'pos'. The elements in this array are:

- style -- Name of the highlight style
- bold -- '1' if style is bold, '0' otherwise
- italic -- '1' if style is italic, '0' otherwise
- color -- Name of the style's color
- rgb -- Color's RGB values ('#rrggbb')
- background -- Name of the background color, if any
- back_rgb -- Background color's RGB values ('#rrggbb')
- extent -- The length in the text which uses the same highlight style

The colors use the names specified in the color definitions for the style. These will either be names matching those the X server recognises, or RGB specifications. The values for 'rgb' and 'back_rgb' contain the actual color values allocated by the X server for the window. If the X server cannot allocate the specified (named) color exactly, the RGB values in these entries may not match the specified ones.

The 'extent' value is measured from position 'pos' going right/down (forward in the file) only.

If 'pos' is invalid, an empty array is returned.