EditorColor

Far Manager

EditorColor

The EditorColor structure is used in the EditorControl function to get or set information about color regions in FAR editor.
struct EditorColor
{
  int StringNumber;
  int ColorItem;
  int StartPos;
  int EndPos;
  int Color;
};

Elements

StringNumber
Line number to process or -1 for current string.
ColorItem
Ordinal number of the color region whose information is to be retrieved. A line consists of a set of segments (regions) all of which can have a different color. Set ColorItem to 0 to retrieve information about the first segment, 1 for the second, and so on.
This field isn't used with the ECTL_ADDCOLOR command. The new color is applied to the whole region between positions StartPos and EndPos, regardless of color regions which existed there before.
StartPos, EndPos
Line region bounds.
Input parameters for the ECTL_ADDCOLOR command and output parameters for the ECTL_GETCOLOR command.
Color
Character color.
Input parameter for the ECTL_ADDCOLOR command and output parameter for the ECTL_GETCOLOR command.
For the ECTL_ADDCOLOR command, if Color is set to 0, EndPos is ignored and the command will remove all existing color regions starting at position StartPos. In the latter case, if StartPos is -1, all color regions for the line will be removed.

Starting with build 1957 FAR highlights the tabulation character to its full length. If it is needed to highlight the tab character as a character of width 1 then in addition to specifying the color for the Color member set the ECF_TAB1 flag (EDITORCOLORFLAGS enum):

FlagDescription
ECF_TAB1 If a tab character is to be found inside a color region, highlight it as a character of width 1.

Remarks

Partial deletion of color regions is not very useful, as FAR does not renormalize the segments as new ones are added, this is the programmer's responsibility. Normally, it is necessary to clear all regions in line, and recreate them as normalized --- non-overlapping --- segments (otherwise the regions will accumulate causing increased memory usage).

Using the Color parameter, the background color can be set also. Furthermore, regardless of line length, you can set a color region starting from the first visible position and ending at the rightmost; this will change the editor background color. Unfortunately this method won't work for files with a line count less than the editor screen height.

See also: