[latexila/structure-actions] Structure action: select: take indentation
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila/structure-actions] Structure action: select: take indentation
- Date: Fri, 1 Jul 2011 21:44:23 +0000 (UTC)
commit da6d0176016ab47d7d44f4f0be319800e0d42136
Author: SÃbastien Wilmet <swilmet src gnome org>
Date: Fri Jul 1 21:16:38 2011 +0200
Structure action: select: take indentation
src/document_structure.vala | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/document_structure.vala b/src/document_structure.vala
index f98a00e..9113fef 100644
--- a/src/document_structure.vala
+++ b/src/document_structure.vala
@@ -572,7 +572,15 @@ public class DocumentStructure : GLib.Object
TextIter? start_iter;
TextIter? end_iter;
if (get_exact_item_bounds (tree_iter, out start_iter, out end_iter))
+ {
+ if (start_iter.get_line () != end_iter.get_line ())
+ {
+ backward_indentation (ref start_iter);
+ backward_indentation (ref end_iter);
+ }
+
_doc.select_range (start_iter, end_iter);
+ }
}
private void comment_item (TreeIter tree_iter)
@@ -841,4 +849,22 @@ public class DocumentStructure : GLib.Object
_doc.get_end_iter (out eof_iter);
return eof_iter;
}
+
+ // If there are some spaces between the beginning of the line and the iter, move
+ // the iter at the beginning of the line.
+ private void backward_indentation (ref TextIter? iter)
+ {
+ return_if_fail (iter != null);
+
+ if (iter.starts_line ())
+ return;
+
+ int line_num = iter.get_line ();
+ TextIter begin_line_iter;
+ _doc.get_iter_at_line (out begin_line_iter, line_num);
+
+ string text_between = _doc.get_text (begin_line_iter, iter, false);
+ if (text_between.strip () == "")
+ iter = begin_line_iter;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]