Revision: 3836 http://geany.svn.sourceforge.net/geany/?rev=3836&view=rev Author: ntrel Date: 2009-06-03 15:42:01 +0000 (Wed, 03 Jun 2009)
Log Message: ----------- Support toggling bold/italic when using a named style, e.g.: commentdockeyword=commentdoc,bold,italic Improve named style docs.
Modified Paths: -------------- trunk/ChangeLog trunk/doc/geany.html trunk/doc/geany.txt trunk/src/highlighting.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-06-02 14:45:23 UTC (rev 3835) +++ trunk/ChangeLog 2009-06-03 15:42:01 UTC (rev 3836) @@ -1,3 +1,11 @@ +2009-06-03 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> + + * src/highlighting.c, doc/geany.txt, doc/geany.html: + Support toggling bold/italic when using a named style, e.g.: + commentdockeyword=commentdoc,bold,italic + Improve named style docs. + + 2009-06-01 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/build.c, src/editor.c:
Modified: trunk/doc/geany.html =================================================================== --- trunk/doc/geany.html 2009-06-02 14:45:23 UTC (rev 3835) +++ trunk/doc/geany.html 2009-06-03 15:42:01 UTC (rev 3836) @@ -6,7 +6,7 @@ <meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" /> <title>Geany</title> <meta name="authors" content="Enrico Tröger Nick Treleaven Frank Lanitz" /> -<meta name="date" content="2009-05-30" /> +<meta name="date" content="2009-06-01" /> <style type="text/css">
/* @@ -139,7 +139,7 @@ <br />Nick Treleaven <br />Frank Lanitz</td></tr> <tr><th class="docinfo-name">Date:</th> -<td>2009-05-30</td></tr> +<td>2009-06-01</td></tr> <tr><th class="docinfo-name">Version:</th> <td>0.18</td></tr> </tbody> @@ -3331,18 +3331,32 @@ <div class="section"> <h4><a class="toc-backref" href="#id145" id="styling-section" name="styling-section">[styling] Section</a></h4> <p>In this section the colors for syntax highlighting are defined. The -format is one of:</p> +manual format is:</p> <ul class="simple"> <li><tt class="docutils literal"><span class="pre">key=foreground_color;background_color;bold;italic</span></tt></li> -<li><tt class="docutils literal"><span class="pre">key=named_style</span></tt></li> </ul> <p>Colors have to be specified as RGB hex values prefixed by 0x. For example red is 0xff0000, blue is 0x0000ff. The values are case-insensitive, but it is a good idea to use small letters. Bold and italic are flags and should only be "true" or "false". If their value is something other than "true" or "false", "false" is assumed.</p> -<p>For named styles, see the filetypes.common <a class="reference" href="#named-styles-section">[named_styles] Section</a>.</p> +<p>The second format uses a <em>named style</em> name to reference a style +defined in filetypes.common.</p> +<ul class="simple"> +<li><tt class="docutils literal"><span class="pre">key=named_style</span></tt></li> +<li><tt class="docutils literal"><span class="pre">key2=named_style2,bold,italic</span></tt></li> +</ul> +<p>The bold and italic parts are optional, and if present are used to +toggle the bold or italic flags to the opposite of the named style's +flags.</p> +<div class="note"> +<p class="first admonition-title">Note</p> +<p class="last">Commas are used for these so Geany can easily determine whether a +named style is used or not.</p> </div> +<p>To define named styles, see the filetypes.common <a class="reference" href="#named-styles-section">[named_styles] +Section</a>.</p> +</div> <div class="section"> <h4><a class="toc-backref" href="#id146" id="keywords-section" name="keywords-section">[keywords] Section</a></h4> <p>This section contains keys for different keyword lists specific to @@ -3469,6 +3483,7 @@ <p>There is a special filetype definition file called filetypes.common. This file defines some general non-filetype-specific settings.</p> +<p>See the <a class="reference" href="#format">Format</a> section for how to define styles.</p> <div class="section"> <h4><a class="toc-backref" href="#id150" id="named-styles-section" name="named-styles-section">[named_styles] Section</a></h4> <p>Named styles declared here can be used in the [styling] section of any @@ -3490,7 +3505,8 @@ <div class="note"> <p class="first admonition-title">Note</p> <p class="last">You can define aliases for named styles, as shown with the <tt class="docutils literal"><span class="pre">bar</span></tt> -entry in the above example.</p> +entry in the above example, but they must be declared after the +original style.</p> </div> </div> <div class="section"> @@ -4915,7 +4931,7 @@ <div class="footer"> <hr class="footer" /> <a class="reference" href="geany.txt">View document source</a>. -Generated on: 2009-06-01 14:31 UTC. +Generated on: 2009-06-03 15:37 UTC. Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
Modified: trunk/doc/geany.txt =================================================================== --- trunk/doc/geany.txt 2009-06-02 14:45:23 UTC (rev 3835) +++ trunk/doc/geany.txt 2009-06-03 15:42:01 UTC (rev 3836) @@ -2924,10 +2924,9 @@ `````````````````
In this section the colors for syntax highlighting are defined. The -format is one of: +manual format is:
* ``key=foreground_color;background_color;bold;italic`` -* ``key=named_style``
Colors have to be specified as RGB hex values prefixed by 0x. For example red is 0xff0000, blue is 0x0000ff. The values are @@ -2935,9 +2934,24 @@ and italic are flags and should only be "true" or "false". If their value is something other than "true" or "false", "false" is assumed.
-For named styles, see the filetypes.common `[named_styles] Section`_. +The second format uses a *named style* name to reference a style +defined in filetypes.common.
+* ``key=named_style`` +* ``key2=named_style2,bold,italic``
+The bold and italic parts are optional, and if present are used to +toggle the bold or italic flags to the opposite of the named style's +flags. + +.. note:: + Commas are used for these so Geany can easily determine whether a + named style is used or not. + +To define named styles, see the filetypes.common `[named_styles] +Section`_. + + [keywords] Section ``````````````````
@@ -3079,6 +3093,9 @@ filetypes.common. This file defines some general non-filetype-specific settings.
+See the `Format`_ section for how to define styles. + + [named_styles] Section `````````````````````` Named styles declared here can be used in the [styling] section of any @@ -3102,8 +3119,10 @@
.. note:: You can define aliases for named styles, as shown with the ``bar`` - entry in the above example. + entry in the above example, but they must be declared after the + original style.
+ [styling] Section ````````````````` default @@ -3282,6 +3301,7 @@
*Example:* ``marker_translucency=256;256;false;false``
+ [settings] Section `````````````````` whitespace_chars
Modified: trunk/src/highlighting.c =================================================================== --- trunk/src/highlighting.c 2009-06-02 14:45:23 UTC (rev 3835) +++ trunk/src/highlighting.c 2009-06-03 15:42:01 UTC (rev 3836) @@ -30,6 +30,7 @@
#include <stdlib.h> #include <ctype.h> +#include <string.h>
#include "SciLexer.h" #include "highlighting.h" @@ -189,12 +190,32 @@ }
-static void read_named_style(const gchar *name, GeanyLexerStyle *style) +static void read_named_style(gchar *name, GeanyLexerStyle *style) { - GeanyLexerStyle *cs = g_hash_table_lookup(named_style_hash, name); + GeanyLexerStyle *cs; + gchar *comma; + const gchar *bold = NULL; + const gchar *italic = NULL;
+ g_return_if_fail(name); + + comma = strstr(name, ","); + if (comma) + { + bold = strstr(comma, ",bold"); + italic = strstr(comma, ",italic"); + *comma = '\0'; /* terminate name to make lookup work */ + } + cs = g_hash_table_lookup(named_style_hash, name); + if (cs) + { *style = *cs; + if (bold) + style->bold = !style->bold; + if (italic) + style->italic = !style->italic; + } else { *style = gsd_default; @@ -221,7 +242,7 @@
if (G_LIKELY(list != NULL) && G_UNLIKELY(list[0] != NULL)) { - const gchar *str = list[0]; + gchar *str = list[0];
if (list[1] == NULL && isalpha(str[0])) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.