From 70fb9ca5c52d16ddcb8f156c11887ffdc0d663a4 Mon Sep 17 00:00:00 2001 From: jhs Date: Wed, 13 Feb 2008 21:14:58 +0000 Subject: [PATCH] 2008-02-13 Johannes Schmid * plugins/language-support-cpp-java/plugin.c: (is_iter_inside_string), (get_line_auto_indentation): Handle comments in the code and do not ask editor. Fixes scintilla indentation (sourceview does not report comments anyway). * plugins/sourceview/sourceview-cell.c: (iiter_diff): Diff with correct sign (also fixes some issues with language-support) git-svn-id: http://svn.gnome.org/svn/anjuta/trunk@3652 1dbfb86a-d425-0410-a06b-cb591aac69f6 --- ChangeLog | 17 +++++++++++++++++ plugins/language-support-cpp-java/plugin.c | 26 ++++++++++++-------------- plugins/sourceview/sourceview-cell.c | 4 ++-- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 18a4d0f0..de9872d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,23 @@ 2008-02-13 Johannes Schmid * plugins/language-support-cpp-java/plugin.c: + (is_iter_inside_string), (get_line_auto_indentation): + Handle comments in the code and do not ask editor. Fixes scintilla + indentation (sourceview does not report comments anyway). + + * plugins/sourceview/sourceview-cell.c: (iiter_diff): + Diff with correct sign (also fixes some issues with language-support) + +2008-02-13 Johannes Schmid,,, + + reviewed by: + + * plugins/language-support-cpp-java/plugin.c: + (is_iter_inside_string), (get_line_auto_indentation): + +2008-02-13 Johannes Schmid + + * plugins/language-support-cpp-java/plugin.c: (get_line_indentation_base): Act even more clever for comments. Indent /* */ comments correctly for multilines diff --git a/plugins/language-support-cpp-java/plugin.c b/plugins/language-support-cpp-java/plugin.c index 84e30faf..f54dea30 100644 --- a/plugins/language-support-cpp-java/plugin.c +++ b/plugins/language-support-cpp-java/plugin.c @@ -916,7 +916,7 @@ get_line_indentation_base (CppJavaPlugin *plugin, * statement could hardly be incomplte. */ if (point_ch == '}' && *incomplete_statement == -1) - *incomplete_statement = 0; + *incomplete_statement = 0; /* If at level 0 indentation, encoutered a * block end, don't bother going further @@ -1110,42 +1110,40 @@ get_line_indentation_base (CppJavaPlugin *plugin, return line_indent; } -/* Check if iter is inside comment or string. Begining of comment or string +/* Check if iter is inside string. Begining of string * is not counted as inside. */ static gboolean -is_iter_inside_comment_or_string (IAnjutaIterable *iter) +is_iter_inside_string (IAnjutaIterable *iter) { IAnjutaEditorAttribute attrib; attrib = ianjuta_editor_cell_get_attribute (IANJUTA_EDITOR_CELL (iter), NULL); - /* Check if we are *inside* comment or string. Begining of comment - * or string does not count as inside. + /* Check if we are *inside* string. Begining + * of string does not count as inside. */ - if (attrib == IANJUTA_EDITOR_COMMENT || attrib == IANJUTA_EDITOR_STRING) + if (attrib == IANJUTA_EDITOR_STRING) { /* Peek previous attrib and see what it was */ if (ianjuta_iterable_previous (iter, NULL)) { attrib = ianjuta_editor_cell_get_attribute (IANJUTA_EDITOR_CELL (iter), NULL); - if (attrib == IANJUTA_EDITOR_COMMENT || - attrib == IANJUTA_EDITOR_STRING) + if (attrib == IANJUTA_EDITOR_STRING) { - /* We are inside comment or string */ + /* We are inside string */ return TRUE; } else { - /* The comment or string just began, not inside. + /* The string just began, not inside. * Restore iter from the peek */ ianjuta_iterable_next (iter, NULL); } } - /* else, there is no previous and so we can't be inside comment - * or string + /* else, there is no previous and so we can't be inside string */ } return FALSE; @@ -1166,7 +1164,7 @@ get_line_auto_indentation (CppJavaPlugin *plugin, IAnjutaEditor *editor, iter = ianjuta_editor_get_line_begin_position (editor, line, NULL); - if (is_iter_inside_comment_or_string (iter)) + if (is_iter_inside_string (iter)) { line_indent = get_line_indentation (editor, line - 1); } @@ -1184,7 +1182,7 @@ get_line_auto_indentation (CppJavaPlugin *plugin, IAnjutaEditor *editor, * or string does not count as inside. If inside, just align with * previous indentation. */ - if (is_iter_inside_comment_or_string (iter)) + if (is_iter_inside_string (iter)) { line_indent = get_line_indentation (editor, line - 1); break; diff --git a/plugins/sourceview/sourceview-cell.c b/plugins/sourceview/sourceview-cell.c index 84540e7d..d5526c16 100644 --- a/plugins/sourceview/sourceview-cell.c +++ b/plugins/sourceview/sourceview-cell.c @@ -298,8 +298,8 @@ iiter_diff (IAnjutaIterable *iter, IAnjutaIterable *other_iter, GError **e) { SourceviewCell* cell = SOURCEVIEW_CELL(iter); SourceviewCell* other_cell = SOURCEVIEW_CELL(other_iter); - return (gtk_text_iter_get_offset (cell->priv->iter) - - gtk_text_iter_get_offset (other_cell->priv->iter)); + return (gtk_text_iter_get_offset (other_cell->priv->iter) + - gtk_text_iter_get_offset (cell->priv->iter)); } static void -- 2.11.4.GIT