gtksourceview2.StyleScheme — StyleScheme object for gtksourceview2.View
class gtksourceview2.StyleScheme(gobject.GObject): |
+-- gobject.GObject +-- gtksourceview2.StyleScheme
|
gtksourceview2.StyleScheme contains all the text styles to be used in gtksourceview2.View and gtksourceview2.Buffer. For instance, it contains text styles for syntax highlighting, it may contain foreground and background color for non-highlighted text, etc.
Style schemes are stored in XML files. The format of scheme file is the following.
The toplevel tag in a style scheme file is <style-scheme>. It has the following attributes:
<code>id</code> (mandatory) | Identifier for the style scheme. This is must be unique among style schemes. |
<code>name</code> (mandatory) | Name of the style scheme. This is the name of the scheme to display to user, e.g. in a preferences dialog. |
<code>_name</code> | This is the same as <code>name</code> attribute, except it will be translated. <code>name</code> and <code>_name</code> may not be used simultaneously. |
<code>parent-scheme</code> (optional) | Style schemes may have parent schemes: all styles but those specified in the scheme will be taken from the parent scheme. In this way a scheme may be customized without copying all its content. |
<code>version</code> (mandatory) | Style scheme format identifier. At the moment it must be "1.0". |
style-scheme tag may contain the following tags:
<code>author</code> | Name of the style scheme author. |
<code>description</code> | Description of the style scheme. |
<code>_description</code> | Same as <code>description</code> except it will be localized. |
<code>color</code> tags | These define color names to be used in <code>style</code> tags. It has two attributes: <code>name</code> and <code>value</code>. <code>value</code> is the hexadecimal color specification like "#000000" or named color understood by Gdk prefixed with "#", e.g. "#beige". |
<code>style</code> tags | See below for their format description. |
Each <code>style</code> tag describes a single element of style scheme (it corresponds to #GtkSourceStyle object). It has the following attributes:
<code>name</code> (mandatory) | Name of the style. It can be anything, syntax highlighting uses lang-id:style-id, and there are few special styles which are used to control general appearance of the text. Style scheme may contain other names to be used in an application. For instance, it may define color to highlight compilation errors in a build log or a color for bookmarks. |
<code>foreground</code> | Foreground color. It may be name defined in one of <code>color</code> tags, or value in hexadecimal format, e.g. "#000000", or symbolic name understood by Gdk, prefixed with "#", e.g. "#magenta" or "#darkred". |
<code>background</code> | Background color. |
<code>italic</code> | "true" or "false" |
<code>bold</code> | "true" or "false" |
<code>underline</code> | "true" or "false" |
<code>strikethrough</code> | "true" or "false" |
The following are names of styles which control #GtkSourceView appearance:
<code>text</code> | Default style of text. |
<code>selection</code> | Style of selected text. |
<code>selection-unfocused</code> | Style of selected text when the widget doesn't have input focus. |
<code>cursor</code> | Text cursor style. Only <code>foreground</code> attribute is used for this style |
<code>secondary-cursor</code> | Secondary cursor style (used in bidi text). Only <code>foreground</code> attribute is used for this style. If this is not set while "cursor" is, then a color between text background and cursor colors is chosen, so it is enough to use "cursor" style only. |
<code>current-line</code> | Current line style. Only <code>background</code> attribute is used |
<code>line-numbers</code> | Text and background colors for the left margin, on which line numbers are drawn |
<code>bracket-match</code> | Style to use for matching brackets. |
<code>bracket-mismatch</code> | Style to use for mismatching brackets. |
def get_authors()
Returns : | a list containing the scheme authors or >None if no author is specified by the style. |
The get_authors() method returns a list of scheme authors.
def get_description()
Returns : | the scheme description (if defined) or None. |
The get_description() method gets the scheme description.
def get_filename()
Returns : | the scheme file name if the scheme was created parsing a style scheme file or None. |
The get_filename() method gets the scheme filename.
def get_id(style_name)
Returns : | the scheme id. |
The get_id() method gets the scheme id.