SF.net SVN: geany:[3155] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sat Oct 25 18:57:00 UTC 2008
Revision: 3155
http://geany.svn.sourceforge.net/geany/?rev=3155&view=rev
Author: eht16
Date: 2008-10-25 18:57:00 +0000 (Sat, 25 Oct 2008)
Log Message:
-----------
Add *_full variants of editor indicator functions to the plugin API for more control over indicators.
Add/Update some API docs.
Make the 'Mark' button for Find highlight the results with rounded boxes instead of marking the whole line.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/geany.html
trunk/doc/geany.txt
trunk/src/callbacks.c
trunk/src/editor.c
trunk/src/editor.h
trunk/src/highlighting.c
trunk/src/plugindata.h
trunk/src/plugins.c
trunk/src/sciwrappers.c
trunk/src/search.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-10-25 18:56:38 UTC (rev 3154)
+++ trunk/ChangeLog 2008-10-25 18:57:00 UTC (rev 3155)
@@ -7,6 +7,14 @@
Add main_locale_init() to the plugin API.
* src/callbacks.c:
Fix updating of the value of the toolbar Goto line spinbutton.
+ * doc/geany.html, doc/geany.txt, src/callbacks.c, src/editor.c,
+ src/editor.h, src/highlighting.c, src/plugindata.h, src/plugins.c,
+ src/sciwrappers.c, src/search.c:
+ Add *_full variants of editor indicator functions to the plugin API
+ for more control over indicators.
+ Add/Update some API docs.
+ Make the 'Mark' button for Find highlight the results with rounded
+ boxes instead of marking the whole line.
2008-10-24 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
Modified: trunk/doc/geany.html
===================================================================
--- trunk/doc/geany.html 2008-10-25 18:56:38 UTC (rev 3154)
+++ trunk/doc/geany.html 2008-10-25 18:57:00 UTC (rev 3155)
@@ -1223,10 +1223,9 @@
<p>Find All In Document will show a list of matching lines in the
current document in the Messages tab of the Message Window. <em>Find All
In Session</em> does the same for all open documents.</p>
-<p>Mark will set markers for all matching lines in the current document,
-if the Markers margin is visible. If not, the background colour of
-matching lines will be highlighted. Markers and highlighting can be
-removed by selecting the Remove Markers command from the Document menu.</p>
+<p>Mark will highlight all matches in the current document with a
+coloured box. These markers can be removed by selecting the
+Remove Markers command from the Document menu.</p>
</div>
<div class="section" id="change-font-in-search-dialog-text-fields">
<h4><a class="toc-backref" href="#id52">Change font in search dialog text fields</a></h4>
@@ -4403,7 +4402,7 @@
<div class="footer">
<hr class="footer" />
<a class="reference external" href="geany.txt">View document source</a>.
-Generated on: 2008-10-23 20:49 UTC.
+Generated on: 2008-10-25 18:46 UTC.
Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
Modified: trunk/doc/geany.txt
===================================================================
--- trunk/doc/geany.txt 2008-10-25 18:56:38 UTC (rev 3154)
+++ trunk/doc/geany.txt 2008-10-25 18:57:00 UTC (rev 3155)
@@ -917,10 +917,9 @@
current document in the Messages tab of the Message Window. *Find All
In Session* does the same for all open documents.
-Mark will set markers for all matching lines in the current document,
-if the Markers margin is visible. If not, the background colour of
-matching lines will be highlighted. Markers and highlighting can be
-removed by selecting the Remove Markers command from the Document menu.
+Mark will highlight all matches in the current document with a
+coloured box. These markers can be removed by selecting the
+Remove Markers command from the Document menu.
Change font in search dialog text fields
Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c 2008-10-25 18:56:38 UTC (rev 3154)
+++ trunk/src/callbacks.c 2008-10-25 18:57:00 UTC (rev 3155)
@@ -1557,7 +1557,7 @@
GeanyDocument *doc = document_get_current();
if (doc != NULL)
- editor_clear_indicators(doc->editor);
+ editor_clear_indicators_full(doc->editor, GEANY_INDICATOR_ERROR);
}
@@ -1917,6 +1917,7 @@
sci_marker_delete_all(doc->editor->sci, 0); /* delete the yellow tag marker */
sci_marker_delete_all(doc->editor->sci, 1); /* delete user markers */
+ editor_clear_indicators_full(doc->editor, GEANY_INDICATOR_SEARCH);
}
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2008-10-25 18:56:38 UTC (rev 3154)
+++ trunk/src/editor.c 2008-10-25 18:57:00 UTC (rev 3155)
@@ -3388,8 +3388,9 @@
* Error indicators (red squiggly underlines) and usual line markers are removed.
*
* @param editor The editor to operate on.
+ * @param indic The indicator number to clear, this is a value of @ref GeanyIndicator.
**/
-void editor_clear_indicators(GeanyEditor *editor)
+void editor_clear_indicators_full(GeanyEditor *editor, gint indic)
{
glong last_pos;
@@ -3397,21 +3398,36 @@
last_pos = sci_get_length(editor->sci);
if (last_pos > 0)
+ {
+ sci_set_indicator(editor->sci, indic);
sci_indicator_clear(editor->sci, 0, last_pos);
+ }
+}
+
+/**
+ * Deletes all currently set indicators in the @a editor window.
+ * Error indicators (red squiggly underlines) and usual line markers are removed.
+ *
+ * @param editor The editor to operate on.
+ **/
+void editor_clear_indicators(GeanyEditor *editor)
+{
+ editor_clear_indicators_full(editor, GEANY_INDICATOR_ERROR);
sci_marker_delete_all(editor->sci, 0); /* remove the yellow error line marker */
}
/**
- * This is a convenience function for editor_set_indicator(). It sets an error indicator
- * (red squiggly underline) on the whole given line.
+ * This is a convenience function for editor_set_indicator_full(). It sets an indicator
+ * on the whole given line.
* Whitespace at the start and the end of the line is not marked.
*
* @param editor The editor to operate on.
+ * @param indic The indicator number to use, this is a value of @ref GeanyIndicator.
* @param line The line number which should be marked.
**/
-void editor_set_indicator_on_line(GeanyEditor *editor, gint line)
+void editor_set_indicator_on_line_full(GeanyEditor *editor, gint indic, gint line)
{
gint start, end;
guint i = 0, len;
@@ -3440,11 +3456,25 @@
}
g_free(linebuf);
- editor_set_indicator(editor, start + i, end);
+ editor_set_indicator_full(editor, indic, start + i, end);
}
/**
+ * This is a convenience function for editor_set_indicator(). It sets an error indicator
+ * (red squiggly underline) on the whole given line.
+ * Whitespace at the start and the end of the line is not marked.
+ *
+ * @param editor The editor to operate on.
+ * @param line The line number which should be marked.
+ **/
+void editor_set_indicator_on_line(GeanyEditor *editor, gint line)
+{
+ editor_set_indicator_on_line_full(editor, GEANY_INDICATOR_ERROR, line);
+}
+
+
+/**
* Sets an error indicator (red squiggly underline) on the range specified by @c start and @c end.
* No error checking or whitespace removal is performed, this should be done by the calling
* function if necessary.
@@ -3455,10 +3485,26 @@
**/
void editor_set_indicator(GeanyEditor *editor, gint start, gint end)
{
+ editor_set_indicator_full(editor, GEANY_INDICATOR_ERROR, start, end);
+}
+
+
+/**
+ * Sets an indicator on the range specified by @c start and @c end.
+ * No error checking or whitespace removal is performed, this should be done by the calling
+ * function if necessary.
+ *
+ * @param editor The editor to operate on.
+ * @param indic The indicator number to use, this is a value of @ref GeanyIndicator.
+ * @param start The starting position for the marker.
+ * @param end The ending position for the marker.
+ **/
+void editor_set_indicator_full(GeanyEditor *editor, gint indic, gint start, gint end)
+{
if (editor == NULL || start >= end)
return;
- sci_set_indicator(editor->sci, 0);
+ sci_set_indicator(editor->sci, indic);
sci_indicator_fill(editor->sci, start, end - start);
}
Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h 2008-10-25 18:56:38 UTC (rev 3154)
+++ trunk/src/editor.h 2008-10-25 18:57:00 UTC (rev 3155)
@@ -50,6 +50,18 @@
}
GeanyAutoIndent;
+/** Geany indicator types, can be used with Editor indicator functions to highlight
+ * text in the document. */
+typedef enum
+{
+ /** Indicator to highlight errors in the document text. This is a red squiggly underline. */
+ GEANY_INDICATOR_ERROR = 0,
+ /** Indicator used to highlight search results in the document. This is a
+ * rounded box around the text. */
+ /* start container indicator outside of lexer indicators (0..7), see Scintilla docs */
+ GEANY_INDICATOR_SEARCH = 8
+}
+GeanyIndicator;
/** Indentation prefs that might be different according to project or filetype.
* Use @c editor_get_indent_prefs() to lookup the prefs for a particular document. */
@@ -206,6 +218,12 @@
void editor_set_font(GeanyEditor *editor, const gchar *font);
+void editor_set_indicator_on_line_full(GeanyEditor *editor, gint indic, gint line);
+
+void editor_set_indicator_full(GeanyEditor *editor, gint indic, gint start, gint end);
+
+void editor_clear_indicators_full(GeanyEditor *editor, gint indic);
+
const gchar *editor_get_eol_char_name(GeanyEditor *editor);
gint editor_get_eol_char_len(GeanyEditor *editor);
Modified: trunk/src/highlighting.c
===================================================================
--- trunk/src/highlighting.c 2008-10-25 18:56:38 UTC (rev 3154)
+++ trunk/src/highlighting.c 2008-10-25 18:57:00 UTC (rev 3155)
@@ -461,10 +461,17 @@
common_style_set.styling[GCS_LINE_WRAP_VISUALS].background, 0);
SSM(sci, SCI_SETWRAPSTARTINDENT, common_style_set.styling[GCS_LINE_WRAP_INDENT].foreground, 0);
- /* indicator settings */
- SSM(sci, SCI_INDICSETSTYLE, 0, INDIC_SQUIGGLE);
- SSM(sci, SCI_INDICSETFORE, 0, invert(0x0000ff));
+ /* Error indicator */
+ SSM(sci, SCI_INDICSETSTYLE, GEANY_INDICATOR_ERROR, INDIC_SQUIGGLE);
+ SSM(sci, SCI_INDICSETFORE, GEANY_INDICATOR_ERROR, invert(rotate_rgb(0xff0000)));
+ /* Search indicator, used for 'Mark' matches */
+ SSM(sci, SCI_INDICSETSTYLE, GEANY_INDICATOR_SEARCH, INDIC_ROUNDBOX);
+ /* TODO make this configurable, but we can't really use the foreground nor the background
+ * colours of GCS_MARKER_LINE since the drawn box is a little translucent and the default
+ * colours for GCS_MARKER_LINE are too bright. */
+ SSM(sci, SCI_INDICSETFORE, GEANY_INDICATOR_SEARCH, invert(rotate_rgb(0x00ff00)));
+
/* define marker symbols
* 0 -> line marker */
SSM(sci, SCI_MARKERDEFINE, 0, SC_MARK_SHORTARROW);
Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h 2008-10-25 18:56:38 UTC (rev 3154)
+++ trunk/src/plugindata.h 2008-10-25 18:57:00 UTC (rev 3155)
@@ -41,7 +41,7 @@
enum {
/** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */
- GEANY_API_VERSION = 103,
+ GEANY_API_VERSION = 104,
/** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */
@@ -289,6 +289,7 @@
gboolean (*has_selection) (struct _ScintillaObject *sci);
gint (*get_tab_width) (struct _ScintillaObject *sci);
void (*indicator_clear) (struct _ScintillaObject *sci, gint start, gint end);
+ void (*set_indicator) (struct _ScintillaObject *sci, gint indic);
}
ScintillaFuncs;
@@ -477,6 +478,10 @@
struct _ScintillaObject* (*create_widget)(struct GeanyEditor *editor);
/* Remember to convert any GeanyDocument or ScintillaObject pointers in any
* appended functions to GeanyEditor pointers. */
+
+ void (*set_indicator_full) (struct GeanyEditor *editor, gint indic, gint start, gint end);
+ void (*set_indicator_on_line_full) (struct GeanyEditor *editor, gint indic, gint line);
+ void (*clear_indicators_full) (struct GeanyEditor *editor, gint indic);
}
EditorFuncs;
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2008-10-25 18:56:38 UTC (rev 3154)
+++ trunk/src/plugins.c 2008-10-25 18:57:00 UTC (rev 3155)
@@ -134,7 +134,10 @@
&editor_set_indicator_on_line,
&editor_clear_indicators,
&editor_get_indent_prefs,
- &editor_create_widget
+ &editor_create_widget,
+ &editor_set_indicator_full,
+ &editor_set_indicator_on_line_full,
+ &editor_clear_indicators_full,
};
static ScintillaFuncs sci_funcs = {
@@ -173,7 +176,8 @@
&sci_get_current_line,
&sci_has_selection,
&sci_get_tab_width,
- &sci_indicator_clear
+ &sci_indicator_clear,
+ &sci_set_indicator
};
static TemplateFuncs template_funcs = {
Modified: trunk/src/sciwrappers.c
===================================================================
--- trunk/src/sciwrappers.c 2008-10-25 18:56:38 UTC (rev 3154)
+++ trunk/src/sciwrappers.c 2008-10-25 18:57:00 UTC (rev 3155)
@@ -972,6 +972,15 @@
return SSM(sci, SCI_GETINDICATORCURRENT, 0, 0);
}
+/**
+ * Set the current indicator. This is necessary to define an indicator for a range of text or
+ * clearing indicators for a range of text.
+ *
+ * @param sci Scintilla widget.
+ * @param indic The indicator number to set.
+ *
+ * @see sci_indicator_clear
+ **/
void sci_set_indicator(ScintillaObject *sci, gint indic)
{
SSM(sci, SCI_SETINDICATORCURRENT, indic, 0);
@@ -982,10 +991,16 @@
SSM(sci, SCI_INDICATORFILLRANGE, pos, len);
}
-/** Clear a range of text from any set indicators. Starting at @a pos, @a len characters long.
- * @param sci Scintilla widget.
- * @param pos Starting position.
- * @param len Length. */
+/**
+ * Clear a range of text from the currently set indicator.
+ * Starting at @a pos, @a len characters long.
+ * In order to make this function properly, you need to set the current indicator before with
+ * @ref sci_set_indicator().
+ *
+ * @param sci Scintilla widget.
+ * @param pos Starting position.
+ * @param len Length.
+ **/
void sci_indicator_clear(ScintillaObject *sci, gint pos, gint len)
{
SSM(sci, SCI_INDICATORCLEARRANGE, pos, len);
Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c 2008-10-25 18:56:38 UTC (rev 3154)
+++ trunk/src/search.c 2008-10-25 18:57:00 UTC (rev 3155)
@@ -801,7 +801,7 @@
static gint search_mark(GeanyDocument *doc, const gchar *search_text, gint flags)
{
- gint pos, line, count = 0;
+ gint pos, end_pos, count = 0;
struct TextToFind ttf;
g_return_val_if_fail(doc != NULL, 0);
@@ -809,13 +809,13 @@
ttf.chrg.cpMin = 0;
ttf.chrg.cpMax = sci_get_length(doc->editor->sci);
ttf.lpstrText = (gchar *)search_text;
- while (1)
+ while (TRUE)
{
pos = sci_find_text(doc->editor->sci, flags, &ttf);
if (pos == -1) break;
- line = sci_get_line_from_position(doc->editor->sci, pos);
- sci_set_marker_at_line(doc->editor->sci, line, TRUE, 1);
+ end_pos = scintilla_send_message(doc->editor->sci, SCI_WORDENDPOSITION, pos, TRUE);
+ editor_set_indicator_full(doc->editor, GEANY_INDICATOR_SEARCH, pos, end_pos);
ttf.chrg.cpMin = ttf.chrgText.cpMax + 1;
count++;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list