Replace the usage of the old Scintilla indicator API by the new modern API and remove old hacks (patch by Jason Oster, thanks).

Add new sci_indic_clear() function to the plugin API.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2966 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2008-09-17 18:05:27 +00:00
parent 5f51987732
commit a6ce9b8a6d
7 changed files with 40 additions and 24 deletions

View File

@ -11,6 +11,11 @@
Rename sci_find_bracematch() into sci_find_matching_brace(). Rename sci_find_bracematch() into sci_find_matching_brace().
* src/main.c: * src/main.c:
Display SVN revision number in version information if available. Display SVN revision number in version information if available.
* src/editor.c, src/highlighting.c, src/plugindata.h, src/plugins.c,
src/sciwrappers.c, src/sciwrappers.h:
Replace the usage of the old Scintilla indicator API by the new
modern API and remove old hacks (patch by Jason Oster, thanks).
Add new sci_indic_clear() function to the plugin API.
2008-09-17 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2008-09-17 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -1467,13 +1467,6 @@ gboolean editor_start_auto_complete(GeanyDocument *doc, gint pos, gboolean force
lexer = SSM(sci, SCI_GETLEXER, 0, 0); lexer = SSM(sci, SCI_GETLEXER, 0, 0);
style = SSM(sci, SCI_GETSTYLEAT, pos - 2, 0); style = SSM(sci, SCI_GETSTYLEAT, pos - 2, 0);
/** TODO if we use other indicators in the future, we should adjust this code, currently
* it works only for the third indicator (INDIC2_MASK) */
if (style & INDIC2_MASK)
{ /* remove the indicator bit from the style */
style &= 0x0000000f;
}
/* don't autocomplete in comments and strings */ /* don't autocomplete in comments and strings */
if (!force && !is_code_style(lexer, style)) if (!force && !is_code_style(lexer, style))
return FALSE; return FALSE;
@ -3277,10 +3270,8 @@ void editor_clear_indicators(GeanyEditor *editor)
last_pos = sci_get_length(editor->sci); last_pos = sci_get_length(editor->sci);
if (last_pos > 0) if (last_pos > 0)
{ sci_indic_clear(editor->sci, 0, last_pos);
sci_start_styling(editor->sci, 0, INDIC2_MASK);
sci_set_styling(editor->sci, last_pos, 0);
}
sci_marker_delete_all(editor->sci, 0); /* remove the yellow error line marker */ sci_marker_delete_all(editor->sci, 0); /* remove the yellow error line marker */
} }
@ -3337,17 +3328,11 @@ void editor_set_indicator_on_line(GeanyEditor *editor, gint line)
**/ **/
void editor_set_indicator(GeanyEditor *editor, gint start, gint end) void editor_set_indicator(GeanyEditor *editor, gint start, gint end)
{ {
gint current_mask;
if (editor == NULL || start >= end) if (editor == NULL || start >= end)
return; return;
current_mask = sci_get_style_at(editor->sci, start); sci_set_indic(editor->sci, 0);
current_mask &= INDICS_MASK; sci_indic_fill(editor->sci, start, end - start);
current_mask |= INDIC2_MASK;
sci_start_styling(editor->sci, start, INDIC2_MASK);
sci_set_styling(editor->sci, end - start, current_mask);
} }

View File

@ -459,10 +459,8 @@ static void styleset_common(ScintillaObject *sci, gint style_bits, filetype_id f
SSM(sci, SCI_SETWRAPSTARTINDENT, common_style_set.styling[GCS_LINE_WRAP_INDENT].foreground, 0); SSM(sci, SCI_SETWRAPSTARTINDENT, common_style_set.styling[GCS_LINE_WRAP_INDENT].foreground, 0);
/* indicator settings */ /* indicator settings */
SSM(sci, SCI_INDICSETSTYLE, 2, INDIC_SQUIGGLE); SSM(sci, SCI_INDICSETSTYLE, 0, INDIC_SQUIGGLE);
/* why? if I let this out, the indicator remains green with PHP */
SSM(sci, SCI_INDICSETFORE, 0, invert(0x0000ff)); SSM(sci, SCI_INDICSETFORE, 0, invert(0x0000ff));
SSM(sci, SCI_INDICSETFORE, 2, invert(0x0000ff));
/* define marker symbols /* define marker symbols
* 0 -> line marker */ * 0 -> line marker */

View File

@ -41,7 +41,7 @@
enum { enum {
/** The Application Programming Interface (API) version, incremented /** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */ * whenever any plugin data types are modified or appended to. */
GEANY_API_VERSION = 93, GEANY_API_VERSION = 94,
/** The Application Binary Interface (ABI) version, incremented whenever /** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */ * existing fields in the plugin data types have to be changed or reordered. */
@ -275,6 +275,7 @@ typedef struct ScintillaFuncs
gint (*get_current_line) (struct _ScintillaObject *sci); gint (*get_current_line) (struct _ScintillaObject *sci);
gboolean (*has_selection) (struct _ScintillaObject *sci); gboolean (*has_selection) (struct _ScintillaObject *sci);
gint (*get_tab_width) (struct _ScintillaObject *sci); gint (*get_tab_width) (struct _ScintillaObject *sci);
gint (*indic_clear) (struct _ScintillaObject *sci, gint start, gint end);
} }
ScintillaFuncs; ScintillaFuncs;

View File

@ -154,7 +154,8 @@ static ScintillaFuncs sci_funcs = {
&sci_get_char_at, &sci_get_char_at,
&sci_get_current_line, &sci_get_current_line,
&sci_has_selection, &sci_has_selection,
&sci_get_tab_width &sci_get_tab_width,
&sci_indic_clear
}; };
static TemplateFuncs template_funcs = { static TemplateFuncs template_funcs = {

View File

@ -1010,6 +1010,26 @@ void sci_start_styling(ScintillaObject *sci, gint pos, gint mask)
SSM(sci, SCI_STARTSTYLING, pos, mask); SSM(sci, SCI_STARTSTYLING, pos, mask);
} }
gint sci_get_indic(ScintillaObject *sci)
{
return SSM(sci, SCI_GETINDICATORCURRENT, 0, 0);
}
void sci_set_indic(ScintillaObject *sci, gint indic)
{
SSM(sci, SCI_SETINDICATORCURRENT, indic, 0);
}
void sci_indic_fill(ScintillaObject *sci, gint pos, gint len)
{
SSM(sci, SCI_INDICATORFILLRANGE, pos, len);
}
void sci_indic_clear(ScintillaObject *sci, gint pos, gint len)
{
SSM(sci, SCI_INDICATORCLEARRANGE, pos, len);
}
void sci_select_all(ScintillaObject *sci) void sci_select_all(ScintillaObject *sci)
{ {
SSM(sci, SCI_SELECTALL, 0, 0); SSM(sci, SCI_SELECTALL, 0, 0);

View File

@ -161,6 +161,12 @@ gint sci_get_first_visible_line (ScintillaObject * sci);
void sci_set_styling (ScintillaObject * sci, gint len, gint style); void sci_set_styling (ScintillaObject * sci, gint len, gint style);
void sci_start_styling (ScintillaObject * sci, gint pos, gint mask); void sci_start_styling (ScintillaObject * sci, gint pos, gint mask);
gint sci_get_indic (ScintillaObject * sci);
void sci_set_indic (ScintillaObject * sci, gint indic);
void sci_indic_fill (ScintillaObject * sci, gint pos, gint len);
void sci_indic_clear (ScintillaObject * sci, gint pos, gint len);
void sci_select_all (ScintillaObject * sci); void sci_select_all (ScintillaObject * sci);
gint sci_get_line_indent_position(ScintillaObject * sci, gint line); gint sci_get_line_indent_position(ScintillaObject * sci, gint line);
void sci_set_line_indentation (ScintillaObject * sci, gint line, gint indent); void sci_set_line_indentation (ScintillaObject * sci, gint line, gint indent);