Change plugin API EditorFuncs to use GeanyEditor pointers.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/editor-struct@2770 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
ad6b64647d
commit
3bdd42ba4b
@ -7,6 +7,9 @@
|
||||
instead.
|
||||
* src/document.c:
|
||||
Fix segfault in update_type_keywords().
|
||||
* src/build.c, src/plugindata.h, src/msgwindow.c, src/callbacks.c,
|
||||
src/editor.c, src/editor.h:
|
||||
Change plugin API EditorFuncs to use GeanyEditor pointers.
|
||||
|
||||
|
||||
2008-07-08 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||
|
@ -380,7 +380,8 @@ static void clear_errors(GeanyDocument *doc)
|
||||
{
|
||||
case GBO_COMPILE:
|
||||
case GBO_MAKE_OBJECT:
|
||||
editor_clear_indicators(doc);
|
||||
g_return_if_fail(doc);
|
||||
editor_clear_indicators(doc->editor);
|
||||
break;
|
||||
|
||||
case GBO_BUILD:
|
||||
@ -392,7 +393,7 @@ static void clear_errors(GeanyDocument *doc)
|
||||
for (i = 0; i < documents_array->len; i++)
|
||||
{
|
||||
if (documents[i]->is_valid)
|
||||
editor_clear_indicators(documents[i]);
|
||||
editor_clear_indicators(documents[i]->editor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -858,7 +859,8 @@ static gboolean build_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data)
|
||||
{
|
||||
GeanyDocument *doc = document_find_by_filename(filename);
|
||||
|
||||
editor_set_indicator_on_line(doc, line - 1); /* will check valid idx */
|
||||
if (doc)
|
||||
editor_set_indicator_on_line(doc->editor, line - 1);
|
||||
color = COLOR_RED; /* error message parsed on the line */
|
||||
}
|
||||
g_free(filename);
|
||||
|
@ -1548,7 +1548,7 @@ on_menu_remove_indicators1_activate (GtkMenuItem *menuitem,
|
||||
GeanyDocument *doc = document_get_current();
|
||||
|
||||
if (doc != NULL)
|
||||
editor_clear_indicators(doc);
|
||||
editor_clear_indicators(doc->editor);
|
||||
}
|
||||
|
||||
|
||||
|
46
src/editor.c
46
src/editor.c
@ -3074,55 +3074,55 @@ void editor_display_current_line(GeanyEditor *editor, gfloat percent_of_view)
|
||||
|
||||
|
||||
/**
|
||||
* Deletes all currently set indicators in the @a document.
|
||||
* Deletes all currently set indicators in the @a editor window.
|
||||
* Error indicators (red squiggly underlines) and usual line markers are removed.
|
||||
*
|
||||
* @param doc The document to operate on.
|
||||
* @param editor The editor to operate on.
|
||||
**/
|
||||
void editor_clear_indicators(GeanyDocument *doc)
|
||||
void editor_clear_indicators(GeanyEditor *editor)
|
||||
{
|
||||
glong last_pos;
|
||||
|
||||
g_return_if_fail(doc != NULL);
|
||||
g_return_if_fail(editor != NULL);
|
||||
|
||||
last_pos = sci_get_length(doc->editor->scintilla);
|
||||
last_pos = sci_get_length(editor->scintilla);
|
||||
if (last_pos > 0)
|
||||
{
|
||||
sci_start_styling(doc->editor->scintilla, 0, INDIC2_MASK);
|
||||
sci_set_styling(doc->editor->scintilla, last_pos, 0);
|
||||
sci_start_styling(editor->scintilla, 0, INDIC2_MASK);
|
||||
sci_set_styling(editor->scintilla, last_pos, 0);
|
||||
}
|
||||
sci_marker_delete_all(doc->editor->scintilla, 0); /* remove the yellow error line marker */
|
||||
sci_marker_delete_all(editor->scintilla, 0); /* remove the yellow error line marker */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is a convenience function for document_set_indicator(). It sets an error indicator
|
||||
* 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 doc The document to operate on.
|
||||
* @param editor The editor to operate on.
|
||||
* @param line The line number which should be marked.
|
||||
**/
|
||||
void editor_set_indicator_on_line(GeanyDocument *doc, gint line)
|
||||
void editor_set_indicator_on_line(GeanyEditor *editor, gint line)
|
||||
{
|
||||
gint start, end;
|
||||
guint i = 0, len;
|
||||
gchar *linebuf;
|
||||
|
||||
if (doc == NULL)
|
||||
if (editor == NULL)
|
||||
return;
|
||||
|
||||
start = sci_get_position_from_line(doc->editor->scintilla, line);
|
||||
end = sci_get_position_from_line(doc->editor->scintilla, line + 1);
|
||||
start = sci_get_position_from_line(editor->scintilla, line);
|
||||
end = sci_get_position_from_line(editor->scintilla, line + 1);
|
||||
|
||||
/* skip blank lines */
|
||||
if ((start + 1) == end ||
|
||||
sci_get_line_length(doc->editor->scintilla, line) == editor_get_eol_char_len(doc))
|
||||
sci_get_line_length(editor->scintilla, line) == editor_get_eol_char_len(editor->document))
|
||||
return;
|
||||
|
||||
/* don't set the indicator on whitespace */
|
||||
len = end - start;
|
||||
linebuf = sci_get_line(doc->editor->scintilla, line);
|
||||
linebuf = sci_get_line(editor->scintilla, line);
|
||||
|
||||
while (isspace(linebuf[i])) i++;
|
||||
while (len > 1 && len > i && isspace(linebuf[len-1]))
|
||||
@ -3132,7 +3132,7 @@ void editor_set_indicator_on_line(GeanyDocument *doc, gint line)
|
||||
}
|
||||
g_free(linebuf);
|
||||
|
||||
editor_set_indicator(doc, start + i, end);
|
||||
editor_set_indicator(editor, start + i, end);
|
||||
}
|
||||
|
||||
|
||||
@ -3141,23 +3141,23 @@ void editor_set_indicator_on_line(GeanyDocument *doc, gint line)
|
||||
* No error checking or whitespace removal is performed, this should be done by the calling
|
||||
* function if necessary.
|
||||
*
|
||||
* @param doc The document to operate on.
|
||||
* @param editor The editor to operate on.
|
||||
* @param start The starting position for the marker.
|
||||
* @param end The ending position for the marker.
|
||||
**/
|
||||
void editor_set_indicator(GeanyDocument *doc, gint start, gint end)
|
||||
void editor_set_indicator(GeanyEditor *editor, gint start, gint end)
|
||||
{
|
||||
gint current_mask;
|
||||
|
||||
if (doc == NULL || start >= end)
|
||||
if (editor == NULL || start >= end)
|
||||
return;
|
||||
|
||||
current_mask = sci_get_style_at(doc->editor->scintilla, start);
|
||||
current_mask = sci_get_style_at(editor->scintilla, start);
|
||||
current_mask &= INDICS_MASK;
|
||||
current_mask |= INDIC2_MASK;
|
||||
|
||||
sci_start_styling(doc->editor->scintilla, start, INDIC2_MASK);
|
||||
sci_set_styling(doc->editor->scintilla, end - start, current_mask);
|
||||
sci_start_styling(editor->scintilla, start, INDIC2_MASK);
|
||||
sci_set_styling(editor->scintilla, end - start, current_mask);
|
||||
}
|
||||
|
||||
|
||||
|
@ -186,11 +186,11 @@ void editor_select_lines(ScintillaObject *sci, gboolean extra_line);
|
||||
|
||||
void editor_select_paragraph(ScintillaObject *sci);
|
||||
|
||||
void editor_set_indicator_on_line(GeanyDocument *doc, gint line);
|
||||
void editor_set_indicator_on_line(GeanyEditor *editor, gint line);
|
||||
|
||||
void editor_set_indicator(GeanyDocument *doc, gint start, gint end);
|
||||
void editor_set_indicator(GeanyEditor *editor, gint start, gint end);
|
||||
|
||||
void editor_clear_indicators(GeanyDocument *doc);
|
||||
void editor_clear_indicators(GeanyEditor *editor);
|
||||
|
||||
void editor_set_font(GeanyDocument *doc, const gchar *font_name, gint size);
|
||||
|
||||
|
@ -603,7 +603,7 @@ gboolean msgwin_goto_compiler_file_line()
|
||||
if (doc != NULL)
|
||||
{
|
||||
if (! doc->changed) /* if modified, line may be wrong */
|
||||
editor_set_indicator_on_line(doc, line - 1);
|
||||
editor_set_indicator_on_line(doc->editor, line - 1);
|
||||
|
||||
ret = navqueue_goto_line(old_doc, doc, line);
|
||||
}
|
||||
|
@ -36,12 +36,12 @@
|
||||
|
||||
/* The API version should be incremented whenever any plugin data types below are
|
||||
* modified or appended to. */
|
||||
static const gint api_version = 76;
|
||||
static const gint api_version = 77;
|
||||
|
||||
/* The ABI version should be incremented whenever existing fields in the plugin
|
||||
* data types below have to be changed or reordered. It should stay the same if fields
|
||||
* are only appended, as this doesn't affect existing fields. */
|
||||
static const gint abi_version = 41;
|
||||
static const gint abi_version = 42;
|
||||
|
||||
/** Check the plugin can be loaded by Geany.
|
||||
* This performs runtime checks that try to ensure:
|
||||
@ -425,12 +425,16 @@ typedef struct NavQueueFuncs
|
||||
NavQueueFuncs;
|
||||
|
||||
|
||||
struct GeanyEditor;
|
||||
|
||||
/* See editor.h */
|
||||
typedef struct EditorFuncs
|
||||
{
|
||||
void (*set_indicator) (struct GeanyDocument *doc, gint start, gint end);
|
||||
void (*set_indicator_on_line) (struct GeanyDocument *doc, gint line);
|
||||
void (*clear_indicators) (struct GeanyDocument *doc);
|
||||
void (*set_indicator) (struct GeanyEditor *editor, gint start, gint end);
|
||||
void (*set_indicator_on_line) (struct GeanyEditor *editor, gint line);
|
||||
void (*clear_indicators) (struct GeanyEditor *editor);
|
||||
/* Remember to convert any GeanyDocument or ScintillaObject pointers in any
|
||||
* appended functions to GeanyEditor pointers. */
|
||||
}
|
||||
EditorFuncs;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user