SF.net SVN: geany: [2587] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Wed May 14 17:59:53 UTC 2008
Revision: 2587
http://geany.svn.sourceforge.net/geany/?rev=2587&view=rev
Author: eht16
Date: 2008-05-14 10:58:56 -0700 (Wed, 14 May 2008)
Log Message:
-----------
Move indicator functions from document.c into editor.c.
Modified Paths:
--------------
trunk/ChangeLog
trunk/plugins/pluginmacros.h
trunk/src/build.c
trunk/src/callbacks.c
trunk/src/document.c
trunk/src/document.h
trunk/src/editor.c
trunk/src/editor.h
trunk/src/msgwindow.c
trunk/src/plugindata.h
trunk/src/plugins.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-05-14 16:44:18 UTC (rev 2586)
+++ trunk/ChangeLog 2008-05-14 17:58:56 UTC (rev 2587)
@@ -20,6 +20,10 @@
the default case.
* src/filetypes.c:
Add shebang detection for Makefiles.
+ * src/build.c, src/plugindata.h, src/msgwindow.c, src/callbacks.c,
+ src/filetypes.c, src/document.c, src/plugins.c, src/document.h,
+ src/main.c, src/editor.c, src/editor.h, plugins/pluginmacros.h:
+ Move indicator functions from document.c into editor.c.
2008-05-14 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/plugins/pluginmacros.h
===================================================================
--- trunk/plugins/pluginmacros.h 2008-05-14 16:44:18 UTC (rev 2586)
+++ trunk/plugins/pluginmacros.h 2008-05-14 17:58:56 UTC (rev 2587)
@@ -55,6 +55,7 @@
#define p_tm geany_data->tm
#define p_ui geany_data->ui
#define p_utils geany_data->utils
+#define p_editor geany_data->editor
#else
Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c 2008-05-14 16:44:18 UTC (rev 2586)
+++ trunk/src/build.c 2008-05-14 17:58:56 UTC (rev 2587)
@@ -377,7 +377,7 @@
{
case GBO_COMPILE:
case GBO_MAKE_OBJECT:
- document_clear_indicators(idx);
+ editor_clear_indicators(idx);
break;
case GBO_BUILD:
@@ -389,7 +389,7 @@
for (i = 0; i < doc_array->len; i++)
{
if (doc_list[i].is_valid)
- document_clear_indicators(i);
+ editor_clear_indicators(i);
}
break;
}
@@ -855,7 +855,7 @@
{
gint idx = document_find_by_filename(filename, FALSE);
- document_set_indicator_on_line(idx, line - 1); /* will check valid idx */
+ editor_set_indicator_on_line(idx, line - 1); /* will check valid idx */
color = COLOR_RED; /* error message parsed on the line */
}
g_free(filename);
Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c 2008-05-14 16:44:18 UTC (rev 2586)
+++ trunk/src/callbacks.c 2008-05-14 17:58:56 UTC (rev 2587)
@@ -1535,7 +1535,7 @@
if (! DOC_IDX_VALID(idx))
return;
- document_clear_indicators(idx);
+ editor_clear_indicators(idx);
}
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2008-05-14 16:44:18 UTC (rev 2586)
+++ trunk/src/document.c 2008-05-14 17:58:56 UTC (rev 2587)
@@ -2192,94 +2192,6 @@
}
-/**
- * Deletes all currently set indicators in the %document.
- * Error indicators (red squiggly underlines) and usual line markers are removed.
- *
- * @param idx The document index to operate on.
- **/
-void document_clear_indicators(gint idx)
-{
- glong last_pos;
-
- g_return_if_fail(DOC_IDX_VALID(idx));
-
- last_pos = sci_get_length(doc_list[idx].sci);
- if (last_pos > 0)
- {
- sci_start_styling(doc_list[idx].sci, 0, INDIC2_MASK);
- sci_set_styling(doc_list[idx].sci, last_pos, 0);
- }
- sci_marker_delete_all(doc_list[idx].sci, 0); /* remove the yellow error line marker */
-}
-
-
-/**
- * This is a convenience function for document_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 idx The %document index to operate on.
- * @param line The line number which should be marked.
- **/
-void document_set_indicator_on_line(gint idx, gint line)
-{
- gint start, end;
- guint i = 0, len;
- gchar *linebuf;
-
- if (! DOC_IDX_VALID(idx))
- return;
-
- start = sci_get_position_from_line(doc_list[idx].sci, line);
- end = sci_get_position_from_line(doc_list[idx].sci, line + 1);
-
- /* skip blank lines */
- if ((start + 1) == end ||
- sci_get_line_length(doc_list[idx].sci, line) == utils_get_eol_char_len(idx))
- return;
-
- /* don't set the indicator on whitespace */
- len = end - start;
- linebuf = sci_get_line(doc_list[idx].sci, line);
-
- while (isspace(linebuf[i])) i++;
- while (len > 1 && len > i && isspace(linebuf[len-1]))
- {
- len--;
- end--;
- }
- g_free(linebuf);
-
- document_set_indicator(idx, start + i, end);
-}
-
-
-/**
- * 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.
- *
- * @param idx The %document index to operate on.
- * @param start The starting position for the marker.
- * @param end The ending position for the marker.
- **/
-void document_set_indicator(gint idx, gint start, gint end)
-{
- gint current_mask;
-
- if (! DOC_IDX_VALID(idx) || start >= end)
- return;
-
- current_mask = sci_get_style_at(doc_list[idx].sci, start);
- current_mask &= INDICS_MASK;
- current_mask |= INDIC2_MASK;
-
- sci_start_styling(doc_list[idx].sci, start, INDIC2_MASK);
- sci_set_styling(doc_list[idx].sci, end - start, current_mask);
-}
-
-
void document_replace_tabs(gint idx)
{
gint search_pos, pos_in_line, current_tab_true_length;
Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h 2008-05-14 16:44:18 UTC (rev 2586)
+++ trunk/src/document.h 2008-05-14 17:58:56 UTC (rev 2587)
@@ -219,12 +219,6 @@
void document_unfold_all(gint idx);
-void document_set_indicator_on_line(gint idx, gint line);
-
-void document_set_indicator(gint idx, gint start, gint end);
-
-void document_clear_indicators(gint idx);
-
void document_replace_tabs(gint idx);
void document_strip_line_trailing_spaces(gint idx, gint line);
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2008-05-14 16:44:18 UTC (rev 2586)
+++ trunk/src/editor.c 2008-05-14 17:58:56 UTC (rev 2587)
@@ -2860,3 +2860,92 @@
}
+/**
+ * Deletes all currently set indicators in the %document.
+ * Error indicators (red squiggly underlines) and usual line markers are removed.
+ *
+ * @param idx The document index to operate on.
+ **/
+void editor_clear_indicators(gint idx)
+{
+ glong last_pos;
+
+ g_return_if_fail(DOC_IDX_VALID(idx));
+
+ last_pos = sci_get_length(doc_list[idx].sci);
+ if (last_pos > 0)
+ {
+ sci_start_styling(doc_list[idx].sci, 0, INDIC2_MASK);
+ sci_set_styling(doc_list[idx].sci, last_pos, 0);
+ }
+ sci_marker_delete_all(doc_list[idx].sci, 0); /* remove the yellow error line marker */
+}
+
+
+/**
+ * This is a convenience function for document_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 idx The %document index to operate on.
+ * @param line The line number which should be marked.
+ **/
+void editor_set_indicator_on_line(gint idx, gint line)
+{
+ gint start, end;
+ guint i = 0, len;
+ gchar *linebuf;
+
+ if (! DOC_IDX_VALID(idx))
+ return;
+
+ start = sci_get_position_from_line(doc_list[idx].sci, line);
+ end = sci_get_position_from_line(doc_list[idx].sci, line + 1);
+
+ /* skip blank lines */
+ if ((start + 1) == end ||
+ sci_get_line_length(doc_list[idx].sci, line) == utils_get_eol_char_len(idx))
+ return;
+
+ /* don't set the indicator on whitespace */
+ len = end - start;
+ linebuf = sci_get_line(doc_list[idx].sci, line);
+
+ while (isspace(linebuf[i])) i++;
+ while (len > 1 && len > i && isspace(linebuf[len-1]))
+ {
+ len--;
+ end--;
+ }
+ g_free(linebuf);
+
+ editor_set_indicator(idx, start + i, end);
+}
+
+
+/**
+ * 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.
+ *
+ * @param idx The %document index to operate on.
+ * @param start The starting position for the marker.
+ * @param end The ending position for the marker.
+ **/
+void editor_set_indicator(gint idx, gint start, gint end)
+{
+ gint current_mask;
+
+ if (! DOC_IDX_VALID(idx) || start >= end)
+ return;
+
+ current_mask = sci_get_style_at(doc_list[idx].sci, start);
+ current_mask &= INDICS_MASK;
+ current_mask |= INDIC2_MASK;
+
+ sci_start_styling(doc_list[idx].sci, start, INDIC2_MASK);
+ sci_set_styling(doc_list[idx].sci, end - start, current_mask);
+}
+
+
+
Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h 2008-05-14 16:44:18 UTC (rev 2586)
+++ trunk/src/editor.h 2008-05-14 17:58:56 UTC (rev 2587)
@@ -21,6 +21,15 @@
* $Id$
*/
+/**
+ * @file editor.h
+ * Callbacks for the Scintilla widget (ScintillaObject).
+ * Most important is the sci-notify callback, handled in on_editor_notification().
+ * This includes auto-indentation, comments, auto-completion, calltips, etc.
+ * Also some general Scintilla-related functions.
+ **/
+
+
#ifndef GEANY_SCI_CB_H
#define GEANY_SCI_CB_H 1
@@ -160,4 +169,10 @@
void editor_select_paragraph(ScintillaObject *sci);
+void editor_set_indicator_on_line(gint idx, gint line);
+
+void editor_set_indicator(gint idx, gint start, gint end);
+
+void editor_clear_indicators(gint idx);
+
#endif
Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c 2008-05-14 16:44:18 UTC (rev 2586)
+++ trunk/src/msgwindow.c 2008-05-14 17:58:56 UTC (rev 2587)
@@ -42,6 +42,7 @@
#include "main.h"
#include "vte.h"
#include "navqueue.h"
+#include "editor.h"
#include <string.h>
#include <stdlib.h>
@@ -542,7 +543,7 @@
if (DOC_IDX_VALID(idx))
{
if (! doc_list[idx].changed) /* if modified, line may be wrong */
- document_set_indicator_on_line(idx, line - 1);
+ editor_set_indicator_on_line(idx, line - 1);
ret = navqueue_goto_line(old_idx, idx, line);
}
Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h 2008-05-14 16:44:18 UTC (rev 2586)
+++ trunk/src/plugindata.h 2008-05-14 17:58:56 UTC (rev 2587)
@@ -176,6 +176,7 @@
struct HighlightingFuncs *highlighting; /**< See highlighting.h */
struct FiletypeFuncs *filetype; /**< See filetypes.h */
struct NavQueueFuncs *navqueue; /**< See navqueue.h */
+ struct EditorFuncs *editor; /**< See editor.h */
}
GeanyData;
@@ -202,9 +203,6 @@
void (*set_encoding) (gint idx, const gchar *new_encoding);
void (*set_text_changed) (gint idx);
void (*set_filetype) (gint idx, filetype *type);
- void (*set_indicator) (gint idx, gint start, gint end);
- void (*set_indicator_on_line) (gint idx, gint line);
- void (*clear_indicators) (gint idx);
}
DocumentFuncs;
@@ -401,6 +399,8 @@
}
TagManagerFuncs;
+
+/* See navqueue.h */
typedef struct NavQueueFuncs
{
gboolean (*goto_line) (gint old_idx, gint new_idx, gint line);
@@ -408,6 +408,16 @@
NavQueueFuncs;
+/* See editor.h */
+typedef struct EditorFuncs
+{
+ void (*set_indicator) (gint idx, gint start, gint end);
+ void (*set_indicator_on_line) (gint idx, gint line);
+ void (*clear_indicators) (gint idx);
+}
+EditorFuncs;
+
+
/* Deprecated aliases */
#ifndef GEANY_DISABLE_DEPRECATED
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2008-05-14 16:44:18 UTC (rev 2586)
+++ trunk/src/plugins.c 2008-05-14 17:58:56 UTC (rev 2587)
@@ -113,12 +113,15 @@
&document_reload_file,
&document_set_encoding,
&document_set_text_changed,
- &document_set_filetype,
- &document_set_indicator,
- &document_set_indicator_on_line,
- &document_clear_indicators
+ &document_set_filetype
};
+static EditorFuncs editor_funcs = {
+ &editor_set_indicator,
+ &editor_set_indicator_on_line,
+ &editor_clear_indicators
+};
+
static ScintillaFuncs sci_funcs = {
&scintilla_send_message,
&sci_cmd,
@@ -264,7 +267,8 @@
&search_funcs,
&highlighting_funcs,
&filetype_funcs,
- &navqueue_funcs
+ &navqueue_funcs,
+ &editor_funcs
};
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