Note: this breaks the plugin API for Editor and Scintilla functions.

Rename all functions in editor.c and sciwrappers.c which are related to indicators for more consistency.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3238 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2008-11-16 17:54:28 +00:00
parent 9975737eff
commit 18095fca79
11 changed files with 54 additions and 90 deletions

View File

@ -11,6 +11,12 @@
Add and use ui_combo_box_prepend_text_once() to add project's
base_path to the Find in Files dialog even if another project was
opened.
* src/build.c, src/callbacks.c, src/editor.c, src/editor.h,
src/msgwindow.c, src/plugindata.h, src/plugins.c, src/sciwrappers.c,
src/sciwrappers.h, src/search.c:
Note: this breaks the plugin API for Editor and Scintilla functions.
Rename all functions in editor.c and sciwrappers.c which are related
to indicators for more consistency.
2008-11-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>

View File

@ -381,7 +381,7 @@ static void clear_errors(GeanyDocument *doc)
case GBO_COMPILE:
case GBO_MAKE_OBJECT:
g_return_if_fail(doc);
editor_clear_indicators(doc->editor);
editor_indicator_clear_errors(doc->editor);
break;
case GBO_BUILD:
@ -393,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);
editor_indicator_clear_errors(documents[i]->editor);
}
break;
}
@ -858,7 +858,7 @@ static gboolean build_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data)
GeanyDocument *doc = document_find_by_filename(filename);
if (doc)
editor_set_indicator_on_line(doc->editor, line - 1);
editor_indicator_set_on_line(doc->editor, GEANY_INDICATOR_ERROR, line - 1);
color = COLOR_RED; /* error message parsed on the line */
}
g_free(filename);

View File

@ -1558,7 +1558,7 @@ on_menu_remove_indicators1_activate (GtkMenuItem *menuitem,
GeanyDocument *doc = document_get_current();
if (doc != NULL)
editor_clear_indicators_full(doc->editor, GEANY_INDICATOR_ERROR);
editor_indicator_clear(doc->editor, GEANY_INDICATOR_ERROR);
}
@ -1918,7 +1918,7 @@ on_remove_markers1_activate (GtkMenuItem *menuitem,
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);
editor_indicator_clear(doc->editor, GEANY_INDICATOR_SEARCH);
}

View File

@ -3443,14 +3443,26 @@ void editor_display_current_line(GeanyEditor *editor, gfloat percent_of_view)
}
/**
/*
* 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_indicator_clear_errors(GeanyEditor *editor)
{
editor_indicator_clear(editor, GEANY_INDICATOR_ERROR);
sci_marker_delete_all(editor->sci, 0); /* remove the yellow error line marker */
}
/**
* Deletes all currently set indicators matching @a indic in the @a editor window.
*
* @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_full(GeanyEditor *editor, gint indic)
void editor_indicator_clear(GeanyEditor *editor, gint indic)
{
glong last_pos;
@ -3459,35 +3471,21 @@ void editor_clear_indicators_full(GeanyEditor *editor, gint indic)
last_pos = sci_get_length(editor->sci);
if (last_pos > 0)
{
sci_set_indicator(editor->sci, indic);
sci_indicator_set(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_full(). It sets an indicator
* on the whole given line.
* Sets an indicator @a indic on @a 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_full(GeanyEditor *editor, gint indic, gint line)
void editor_indicator_set_on_line(GeanyEditor *editor, gint indic, gint line)
{
gint start, end;
guint i = 0, len;
@ -3504,10 +3502,10 @@ void editor_set_indicator_on_line_full(GeanyEditor *editor, gint indic, gint lin
sci_get_line_length(editor->sci, line) == editor_get_eol_char_len(editor))
return;
/* don't set the indicator on whitespace */
len = end - start;
linebuf = sci_get_line(editor->sci, line);
/* don't set the indicator on whitespace */
while (isspace(linebuf[i])) i++;
while (len > 1 && len > i && isspace(linebuf[len-1]))
{
@ -3516,36 +3514,7 @@ void editor_set_indicator_on_line_full(GeanyEditor *editor, gint indic, gint lin
}
g_free(linebuf);
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.
*
* @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(GeanyEditor *editor, gint start, gint end)
{
editor_set_indicator_full(editor, GEANY_INDICATOR_ERROR, start, end);
editor_indicator_set_on_range(editor, indic, start + i, end);
}
@ -3559,12 +3528,12 @@ void editor_set_indicator(GeanyEditor *editor, gint start, gint end)
* @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)
void editor_indicator_set_on_range(GeanyEditor *editor, gint indic, gint start, gint end)
{
if (editor == NULL || start >= end)
return;
sci_set_indicator(editor->sci, indic);
sci_indicator_set(editor->sci, indic);
sci_indicator_fill(editor->sci, start, end - start);
}

View File

@ -210,19 +210,15 @@ void editor_select_lines(GeanyEditor *editor, gboolean extra_line);
void editor_select_paragraph(GeanyEditor *editor);
void editor_set_indicator_on_line(GeanyEditor *editor, gint line);
void editor_set_indicator(GeanyEditor *editor, gint start, gint end);
void editor_clear_indicators(GeanyEditor *editor);
void editor_set_font(GeanyEditor *editor, const gchar *font);
void editor_set_indicator_on_line_full(GeanyEditor *editor, gint indic, gint line);
void editor_indicator_set_on_line(GeanyEditor *editor, gint indic, gint line);
void editor_set_indicator_full(GeanyEditor *editor, gint indic, gint start, gint end);
void editor_indicator_clear_errors(GeanyEditor *editor);
void editor_clear_indicators_full(GeanyEditor *editor, gint indic);
void editor_indicator_set_on_range(GeanyEditor *editor, gint indic, gint start, gint end);
void editor_indicator_clear(GeanyEditor *editor, gint indic);
const gchar *editor_get_eol_char_name(GeanyEditor *editor);

View File

@ -605,7 +605,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->editor, line - 1);
editor_indicator_set_on_line(doc->editor, GEANY_INDICATOR_ERROR, line - 1);
ret = navqueue_goto_line(old_doc, doc, line);
}

View File

@ -45,13 +45,13 @@
enum {
/** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */
GEANY_API_VERSION = 107,
GEANY_API_VERSION = 108,
/** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */
/* This should usually stay the same if fields are only appended, assuming only pointers to
* structs and not structs themselves are declared by plugins. */
GEANY_ABI_VERSION = 49
GEANY_ABI_VERSION = 50
};
/** Check the plugin can be loaded by Geany.
@ -293,7 +293,7 @@ typedef struct ScintillaFuncs
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);
void (*indicator_set) (struct _ScintillaObject *sci, gint indic);
}
ScintillaFuncs;
@ -475,16 +475,12 @@ struct GeanyEditor;
/* See editor.h */
typedef struct EditorFuncs
{
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);
const struct GeanyIndentPrefs* (*get_indent_prefs)(struct GeanyEditor *editor);
struct _ScintillaObject* (*create_widget)(struct GeanyEditor *editor);
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);
void (*indicator_set_on_range) (struct GeanyEditor *editor, gint indic, gint start, gint end);
void (*indicator_set_on_line) (struct GeanyEditor *editor, gint indic, gint line);
void (*indicator_clear) (struct GeanyEditor *editor, gint indic);
void (*set_indent_type)(struct GeanyEditor *editor, GeanyIndentType type);

View File

@ -130,14 +130,11 @@ static DocumentFuncs doc_funcs = {
};
static EditorFuncs editor_funcs = {
&editor_set_indicator,
&editor_set_indicator_on_line,
&editor_clear_indicators,
&editor_get_indent_prefs,
&editor_create_widget,
&editor_set_indicator_full,
&editor_set_indicator_on_line_full,
&editor_clear_indicators_full,
&editor_indicator_set_on_range,
&editor_indicator_set_on_line,
&editor_indicator_clear,
&editor_set_indent_type
};
@ -178,7 +175,7 @@ static ScintillaFuncs sci_funcs = {
&sci_has_selection,
&sci_get_tab_width,
&sci_indicator_clear,
&sci_set_indicator
&sci_indicator_set
};
static TemplateFuncs template_funcs = {

View File

@ -967,7 +967,7 @@ void sci_start_styling(ScintillaObject *sci, gint pos, gint mask)
SSM(sci, SCI_STARTSTYLING, pos, mask);
}
gint sci_get_indicator(ScintillaObject *sci)
gint sci_indicator_get(ScintillaObject *sci)
{
return SSM(sci, SCI_GETINDICATORCURRENT, 0, 0);
}
@ -981,7 +981,7 @@ gint sci_get_indicator(ScintillaObject *sci)
*
* @see sci_indicator_clear
**/
void sci_set_indicator(ScintillaObject *sci, gint indic)
void sci_indicator_set(ScintillaObject *sci, gint indic)
{
SSM(sci, SCI_SETINDICATORCURRENT, indic, 0);
}

View File

@ -162,8 +162,8 @@ gint sci_get_first_visible_line (ScintillaObject * sci);
void sci_set_styling (ScintillaObject * sci, gint len, gint style);
void sci_start_styling (ScintillaObject * sci, gint pos, gint mask);
gint sci_get_indicator (ScintillaObject * sci);
void sci_set_indicator (ScintillaObject * sci, gint indic);
gint sci_indicator_get (ScintillaObject * sci);
void sci_indicator_set (ScintillaObject * sci, gint indic);
void sci_indicator_fill (ScintillaObject * sci, gint pos, gint len);
void sci_indicator_clear (ScintillaObject * sci, gint pos, gint len);

View File

@ -857,7 +857,7 @@ static gint search_mark(GeanyDocument *doc, const gchar *search_text, gint flags
g_return_val_if_fail(doc != NULL, 0);
/* clear previous search indicators */
editor_clear_indicators_full(doc->editor, GEANY_INDICATOR_SEARCH);
editor_indicator_clear(doc->editor, GEANY_INDICATOR_SEARCH);
len = strlen(search_text);
@ -869,7 +869,7 @@ static gint search_mark(GeanyDocument *doc, const gchar *search_text, gint flags
pos = sci_find_text(doc->editor->sci, flags, &ttf);
if (pos == -1) break;
editor_set_indicator_full(doc->editor, GEANY_INDICATOR_SEARCH, pos, pos + len);
editor_indicator_set_on_range(doc->editor, GEANY_INDICATOR_SEARCH, pos, pos + len);
ttf.chrg.cpMin = ttf.chrgText.cpMax + 1;
count++;