gedit style schemes

Yesterday night I released new developement versions of GtkSourceView, PyGtkSourceView and gedit. With this release of gedit one of the more important features of gtksourceview 2 will be visible: style schemes support.

Style Scheme selector

As you can see from the screenshot the old Syntax Highlighting preferences and the color buttons to set text and background colors are gone, replaced by the selection of the style scheme. A style scheme takes care of all of the syntax highlighting colors and also allows to set some more customizations (for instance the current line highlighting color). The plan was to have a simple style scheme editor to create and tweak style schemes from the GUI, but at this point it looks unlikely for 2.20, also because figuring out the proper UI is not as trivial as one may first think. If the lack of a GUI to edit colors really bothers you, feedback is welcome, especially with patches attached :)

At least I’ll try to add buttons to install and remove schemes from file in the hope that a good collection of third party schemes will be soon available. By the way, if any of the Gnome Online people want to give it a try at creating a service to install Style Schemes from an online collection I surely will not oppose.

Creating a style scheme is very simple: just create yourtheme.xml and drop it in ~/.local/share/gtksourceview-2.0/styles.

The file format is very simple, as you can see from this quick example I put together, a lowcontrast dark style with tango colors: darktango.xml

darktango

It is basically a list of:

<style name="element" foreground="color" background="color"/>

Where element can be one of the builtin elements (like “text” or “bracket-match”) or a syntax element specified in the form “language_id:element_id” and color can be either specified directly as #NNNNN or defined in a palette.

“def:element_id” stands for the default style for those kind of elements, since GtkSourceView tries to map the styles to reasonable defaults. Let’s make an example: if I write “while” in a C file, gtksourceview will try to lookup the c:keyword style, if that is not defined it will try to use def:keyword and if that is not defined either it will use def:statement.

The minimal set of styles you need to define are def:comment, def:constant, def:statement, def:identifier, def:type and def:preprocessor, but obviously for good looking schemes some more tweaking is needed, like defining def:error or distinguishing def:string from def:constant etc. You will also probably need to define some language specific things, especially for things like diff files or xml files that do not easily map to those default styles.

As said above we are really looking forward to see style schemes created by our users, thus we started a wiki page to collect them. Beside we are also looking forward including the best ones in GtkSourceView itself: currently we have the classic style (similar to gvim colors) the Kate style (similar to the Kate editor colors) and a Tango style, which however still needs a bit of tweaking since at least in my opinion it looks “too light”. We would like to include a couple more styles in gtksourceview of which at least one for dark backgrounds, so if you come up with a good theme or improve one of the existing ones (in particular tango.xml) do not esitate to tell us!

7 Responses to “gedit style schemes”

  1. panos Says:

    Hey, my theme!

    http://www.vim.org/scripts/script.php?script_id=1672

    no, kudos? :)

  2. pbor Says:

    panos: I started off with a scheme done by Paolo Maggi, but ended up changing most of the colors. I am not sure if he started with your theme or if the use of the same name is simply due to using the tango palette on a dark background

  3. Tobias Says:

    Someone should hack up a GVim to gtksourceview color scheme converter …

  4. je Says:

    This is great!

  5. kaiska Says:

    Nice ! I’m looking for a similar scheme for geany. Any idea ?

  6. panos Says:

    pbor: no prob mate, I still get a bit of that feeling of satisfaction :)

    gj on the releases too!

  7. Gustavo Carneiro Says:

    My Emacs color scheme:

    http://gjcarneiro.blogspot.com/2007/08/gedit-with-emacs-colors.html

    Post also includes a list of some features found in gnu emacs that I miss in gedit :P

Leave a Reply