eye.helpers.lexercolor module¶
Color scheme application
This plugin allows to load color scheme definition from a file and apply them to editor and syntax coloring.
Color scheme format¶
Color scheme files are in INI format (as read by configparser). A scheme file sets style attributes for multiples lexers and such descriptions can be applied to an editor.
Sections¶
A color scheme file consist in one or more INI sections, each corresponding to a lexer. The special section * applies to all lexers. When applying a color scheme to an editor, the * section is applied first if it exists, then the section for the lexer of the editor is applied, if it exists and if the editor has a lexer.
Attributes¶
Within a section, there are multiple entries in the form: item_kind.item_name.style_property = style_value.
The item_kind.item_name part specifies for which items of the lexer it should apply, for example: the “keyword” token, the “search” indicator, or simply the caret style.
The style_property indicates what attribute should be set, for example: the font size, the background color.
Finally, the style_value is the value the style_property should be set to, for example: a color, a size, a font name.
Item types¶
Editor properties¶
If item_kind is base, item_name can be:
text: applies to normal text
selection’: applies to selected text
whitespace
caret: applies to caret, for foreground, or whole line under cursor, for background (if set visible)
hotspot
matchedbrace: for a brace under cursor, which has a corresponding matching brace
unmatchedbrace: for a brace under cursor, which doesn’t have a corresponding matching brace
margin: for the margin column
The valid style_property are foreground, background, font, points, bold, italic, underline.
Tokens¶
If item_kind is token, item_name is the token name, which corresponds to one style in QsciLexer.
The token name * is special: it matches all tokens, and is applied first, so it can be overwritten by more specific color scheme entries.
The valid style_property are foreground, background, font, points, bold, italic, underline.
Styles¶
If item_kind is style, item_name is the style name, as registered in eye.helpers.styles module.
The valid style_property are foreground, background, font, points, bold, italic, underline and eolfill.
Indicators¶
If item_kind is indicator, item_name is the indicator name (see eye.widgets.editor.Editor.indicators
)
The valid style_property are: foreground, background and style.
Property types¶
foreground (or fg, or color) specifies the text color
background (or bg) specifies the background color
font specifies the font family (font name)
points specifies the font size in points
bold specifies whether the font is bold
italic specifies whether the font is italic
underline specifies whether the font is underline
eolfill specifies whether the background color applies to the rest of the line, after last character
style specifies which indicator style should be used, e.g. StraightBoxIndicator
Module contents¶
- eye.helpers.lexercolor.add_scheme_file(path, apply_to_all=True)[source]¶
Load a color scheme file
Unlike
use_scheme_file
, it does not reset the current color scheme but adds new definitions. If a previous scheme file had some definitions which are redefined in the new scheme, they are replaced by the new one.- Parameters:
path – color scheme file
apply_to_all – if True, apply to existing editor widgets
- eye.helpers.lexercolor.apply_scheme_on_create(editor)[source]¶
This handler is disabled by default.
This handler is registered as setup for categories
['editor']
.
- eye.helpers.lexercolor.apply_scheme_on_lexer_change(editor, lexer)[source]¶
This handler is disabled by default.
This handler is registered for categories
['editor']
on signallexer_changed
.
- eye.helpers.lexercolor.lexer_set_font_family(lexer, family, style=-1)[source]¶
Set the font family of a lexer
Set just the font family for style of lexer. Like
QsciLexer.setFont
, but only change the font family, not font size or weight.- Parameters:
lexer (QsciLexer) – the lexer to change
family – font family to use
style – if negative, modifies all styles of lexer
- eye.helpers.lexercolor.lexer_set_font_point_size(lexer, size, style=-1)[source]¶
Set the font size of a lexer
Set just the font size for style of lexer. Like
QsciLexer.setFont
, but only change the font size, not font family or weight.- Parameters:
lexer (QsciLexer) – the lexer to change
size – font size to use (in points)
style – if negative, modifies all styles of lexer