[geany/geany] 9ddeed: Enable entity completion for XML documents
Nick Treleaven
git-noreply at xxxxx
Thu Jul 26 00:04:01 UTC 2012
Branch: refs/heads/document-messages
Author: Nick Treleaven <nick.treleaven at btinternet.com>
Committer: Nick Treleaven <nick.treleaven at btinternet.com>
Date: Fri, 13 Apr 2012 16:41:52
Commit: 9ddeed5254dbb2b23a18c2685d4f2e2d2b224eed
https://github.com/geany/geany/commit/9ddeed5254dbb2b23a18c2685d4f2e2d2b224eed
Log Message:
-----------
Enable entity completion for XML documents
Modified Paths:
--------------
src/editor.c
src/highlighting.c
Modified: src/editor.c
21 files changed, 11 insertions(+), 10 deletions(-)
===================================================================
@@ -2031,8 +2031,7 @@ gchar *editor_get_calltip_text(GeanyEditor *editor, const TMTag *tag)
}
-static gboolean autocomplete_check_html(GeanyEditor *editor, gint style,
- const gchar *root, gint rootlen)
+static gboolean autocomplete_check_html(GeanyEditor *editor, gint style, gint pos)
{
GeanyFiletype *ft = editor->document->file_type;
gboolean try = FALSE;
@@ -2041,6 +2040,8 @@ static gboolean autocomplete_check_html(GeanyEditor *editor, gint style,
* (everything after SCE_HJ_START is for embedded scripting languages) */
if (ft->id == GEANY_FILETYPES_HTML && style < SCE_HJ_START)
try = TRUE;
+ else if (sci_get_lexer(editor->sci) == SCLEX_XML)
+ try = TRUE;
else if (ft->id == GEANY_FILETYPES_PHP)
{
/* use entity completion when style is outside of PHP styles */
@@ -2049,15 +2050,17 @@ static gboolean autocomplete_check_html(GeanyEditor *editor, gint style,
}
if (try)
{
+ gchar root[GEANY_MAX_WORD_LENGTH];
+ gchar *tmp;
+
+ read_current_word(editor, pos, root, sizeof(root), GEANY_WORDCHARS"&", TRUE);
+
/* Allow something like ""some text"".
* for entity completion we want to have completion for '&' within words. */
- gchar *tmp = strchr(root, '&');
-
+ tmp = strchr(root, '&');
if (tmp != NULL)
{
- root = tmp;
- rootlen = strlen(tmp);
- return autocomplete_html(editor->sci, root, rootlen);
+ return autocomplete_html(editor->sci, tmp, strlen(tmp));
}
}
return FALSE;
@@ -2188,8 +2191,6 @@ gboolean editor_start_auto_complete(GeanyEditor *editor, gint pos, gboolean forc
if (ft->id == GEANY_FILETYPES_LATEX)
wordchars = GEANY_WORDCHARS"\\"; /* add \ to word chars if we are in a LaTeX file */
- else if (ft->id == GEANY_FILETYPES_HTML || ft->id == GEANY_FILETYPES_PHP)
- wordchars = GEANY_WORDCHARS"&"; /* add & to word chars if we are in a PHP or HTML file */
else
wordchars = GEANY_WORDCHARS;
@@ -2199,7 +2200,7 @@ gboolean editor_start_auto_complete(GeanyEditor *editor, gint pos, gboolean forc
if (rootlen > 0)
{
- ret = autocomplete_check_html(editor, style, root, rootlen);
+ ret = autocomplete_check_html(editor, style, pos);
if (ret || (ft->id == GEANY_FILETYPES_PHP && style == SCE_HPHP_DEFAULT &&
rootlen == 3 && strcmp(root, "php") == 0 && pos >= 5 &&
sci_get_char_at(sci, pos - 5) == '<' &&
Modified: src/highlighting.c
2 files changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -1479,6 +1479,7 @@ gboolean highlighting_is_string_style(gint lexer, gint style)
return (style == SCE_MATLAB_STRING ||
style == SCE_MATLAB_DOUBLEQUOTESTRING);
+ case SCLEX_XML:
case SCLEX_HTML:
return (
style == SCE_HBA_STRING ||
@@ -1631,6 +1632,7 @@ gboolean highlighting_is_comment_style(gint lexer, gint style)
case SCLEX_YAML:
return (style == SCE_YAML_COMMENT);
+ case SCLEX_XML:
case SCLEX_HTML:
return (
style == SCE_HBA_COMMENTLINE ||
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
More information about the Commits
mailing list