Branch: refs/heads/master Author: Frank Lanitz frank@frank.uvena.de Committer: Frank Lanitz frank@frank.uvena.de Date: Thu, 21 Nov 2013 12:18:06 UTC Commit: e327c76188a738f5c3d2bdaccb3fb06a99eccb39 https://github.com/geany/geany-plugins/commit/e327c76188a738f5c3d2bdaccb3fb0...
Log Message: ----------- Merge pull request #127 from vmkononenko/master
Update PairTagHighlighter to version 1.1
Modified Paths: -------------- pairtaghighlighter/ChangeLog pairtaghighlighter/src/pair_tag_highlighter.c
Modified: pairtaghighlighter/ChangeLog 9 files changed, 9 insertions(+), 0 deletions(-) =================================================================== @@ -1,3 +1,12 @@ +Changes in v1.1 Nov 19, 2013 + + * Add HTML empty tags support according to HTML5 standard. + * Add red and yellow colors to define if pair is found or tag is + empty. + * Enable XML support. + * Improved brackets search by ignoring php tags (<? <?php ?>) and + object operators (->). Thanks Peter Donin for bugreport! + Changes in v1.0 Apr 5, 2013
* The first public version.
Modified: pairtaghighlighter/src/pair_tag_highlighter.c 65 files changed, 44 insertions(+), 21 deletions(-) =================================================================== @@ -34,7 +34,7 @@
PLUGIN_SET_TRANSLATABLE_INFO(LOCALEDIR, GETTEXT_PACKAGE, _("Pair Tag Highlighter"), _("Finds and highlights matching opening/closing HTML tag"), - "1.0", "Volodymyr Kononenko vm@kononenko.ws") + "1.1", "Volodymyr Kononenko vm@kononenko.ws")
/* Searches tag brackets. @@ -55,13 +55,26 @@ static gint findBracket(ScintillaObject *sci, gint position, gint endOfSearchPos for(pos=position; pos<=endOfSearchPos; pos++) { gchar charAtCurPosition = sci_get_char_at(sci, pos); - if(charAtCurPosition == searchedBracket) - { + gchar charAtPrevPosition = sci_get_char_at(sci, pos-1); + gchar charAtNextPosition = sci_get_char_at(sci, pos+1); + + if(charAtCurPosition == searchedBracket) { + if ('>' == searchedBracket) { + if (('-' == charAtPrevPosition) || ('?' == charAtPrevPosition)) + continue; + } else if ('<' == searchedBracket) { + if ('?' == charAtNextPosition) + continue; + } foundBracket = pos; break; - } - if(charAtCurPosition == breakBracket) + } else if(charAtCurPosition == breakBracket) { + if ('<' == breakBracket) { + if ('?' == charAtNextPosition) + continue; + } break; + } } } else @@ -70,13 +83,27 @@ static gint findBracket(ScintillaObject *sci, gint position, gint endOfSearchPos for(pos=position-1; pos>=endOfSearchPos; pos--) { gchar charAtCurPosition = sci_get_char_at(sci, pos); + gchar charAtPrevPosition = sci_get_char_at(sci, pos+1); + gchar charAtNextPosition = sci_get_char_at(sci, pos-1); + if(charAtCurPosition == searchedBracket) { + if ('<' == searchedBracket) { + if ('?' == charAtPrevPosition) + continue; + } else if ('>' == searchedBracket) { + if (('-' == charAtNextPosition) || ('?' == charAtNextPosition)) + continue; + } foundBracket = pos; break; - } - if(charAtCurPosition == breakBracket) + } else if(charAtCurPosition == breakBracket) { + if ('>' == breakBracket) { + if (('-' == charAtNextPosition) || ('?' == charAtNextPosition)) + continue; + } break; + } } }
@@ -251,8 +278,8 @@ static void findMatchingClosingTag(ScintillaObject *sci, gchar *tagName, gint cl /* are we inside tag? */ gint lineNumber = sci_get_line_from_position(sci, pos); gint lineEnd = sci_get_line_end_position(sci, lineNumber); - gint matchingOpeningBracket = findBracket(sci, pos, endOfDocument, '<', '\0', TRUE); - gint matchingClosingBracket = findBracket(sci, pos, endOfDocument, '>', '\0', TRUE); + gint matchingOpeningBracket = findBracket(sci, pos, lineEnd, '<', '\0', TRUE); + gint matchingClosingBracket = findBracket(sci, pos, lineEnd, '>', '\0', TRUE);
if(-1 != matchingOpeningBracket && -1 != matchingClosingBracket && (matchingClosingBracket > matchingOpeningBracket)) @@ -271,14 +298,7 @@ static void findMatchingClosingTag(ScintillaObject *sci, gchar *tagName, gint cl } pos = matchingClosingBracket; } - /* Speed up search: if findBracket returns -1, that means end of line - * is reached. There is no need to go through the same positions again. - * Jump to the end of line */ - else if(-1 == matchingOpeningBracket || -1 == matchingClosingBracket) - { - pos = lineEnd; - continue; - } + if(openingTagsCount == closingTagsCount) { /* matching tag is found */ @@ -339,10 +359,13 @@ static void run_tag_highlighter(ScintillaObject *sci) clear_previous_highlighting(sci, highlightedBrackets[2], highlightedBrackets[3]); }
- highlightedBrackets[0] = openingBracket; - highlightedBrackets[1] = closingBracket; + /* Don't run search on empty brackets <> */ + if (closingBracket - openingBracket > 1) { + highlightedBrackets[0] = openingBracket; + highlightedBrackets[1] = closingBracket;
- findMatchingTag(sci, openingBracket, closingBracket); + findMatchingTag(sci, openingBracket, closingBracket); + } }
@@ -353,7 +376,7 @@ static gboolean on_editor_notify(GObject *obj, GeanyEditor *editor, gint lexer;
lexer = sci_get_lexer(editor->sci); - if(lexer != SCLEX_HTML) + if((lexer != SCLEX_HTML) && (lexer != SCLEX_XML)) { return FALSE; }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org