[latexila/structure-actions] Structure action: select (finished)
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila/structure-actions] Structure action: select (finished)
- Date: Fri, 1 Jul 2011 13:22:31 +0000 (UTC)
commit cc35c9e2f275662377165fb6a4492c0ef63765dd
Author: SÃbastien Wilmet <swilmet src gnome org>
Date: Fri Jul 1 15:21:28 2011 +0200
Structure action: select (finished)
TODO | 16 ++++++++++-
src/document_structure.vala | 61 +++++++++++++++++++++++++++++++++++++++++++
src/structure.vala | 1 +
3 files changed, 76 insertions(+), 2 deletions(-)
---
diff --git a/TODO b/TODO
index 5d82ad1..c9fcfd1 100644
--- a/TODO
+++ b/TODO
@@ -8,16 +8,28 @@ LaTeXila 2.2
- Structure (list of chapters, sections, etc. to easily navigate in a document):
- Right click:
- - cut, copy, delete, select
- - comment
+ - cut, copy, delete
+ - comment: remove the item(s) from the model when the item is commented
- shift left
- shift right:
- display a warning if a subparagraph already exists
+ - display a warning if the action fails (most probably when the structure data
+ is not up-to-date)
Shift left/right is new comparated to Kile. For example we have a big section (with
subsections, etc.) and we want to shift it to the left so it becomes a chapter (the
subsections becomes sections, etc.).
+ - When setting a model, expand all only if the tree is not too big
+
+ - Insert in middle is very slow comparated to insert at the end
+ => Insert environments as soon as we find the \begin, and then update the item (or delete it)
+
+ - Create the TextMarks at the right places with get_iter_at_line_index(),
+ and simplify the code for actions
+
+ - Take into account \end{document}
+
- Write some documentation:
- explain the build tools, how to create a new one, etc.
- the difference between Latexmk and Rubber
diff --git a/src/document_structure.vala b/src/document_structure.vala
index fa5abf1..12a3e0b 100644
--- a/src/document_structure.vala
+++ b/src/document_structure.vala
@@ -680,10 +680,66 @@ public class DocumentStructure : GLib.Object
/* search 'end_iter' */
+ // a section
if (Structure.is_section (item_type))
{
+ TreeIter? next_section_iter = null;
+ try
+ {
+ next_section_iter = _model.get_next_sibling_or_parent (tree_iter);
+ }
+ catch (StructError e)
+ {
+ stderr.printf ("Structure: get next sibling or parent: %s\n", e.message);
+ return false;
+ }
+
+ // the end of the section is the end of the document
+ if (next_section_iter == null)
+ {
+ _doc.get_end_iter (out end_iter);
+ return true;
+ }
+
+ _model.get (next_section_iter,
+ StructColumn.TYPE, out item_type,
+ StructColumn.START_MARK, out start_mark,
+ StructColumn.TEXT, out item_contents,
+ -1);
+
+ _doc.get_iter_at_mark (out line_iter, start_mark);
+ line_num = line_iter.get_line ();
+
+ found = get_low_level_item_bounds (item_type, item_contents, line_num, true,
+ out start_match_index, null);
+
+ if (! found)
+ return false;
+
+ _doc.get_iter_at_line_index (out end_iter, line_num, start_match_index);
+ return true;
+ }
+
+ // an other common type
+ else if (item_type < StructType.NB_COMMON_TYPES)
+ {
+ _doc.get_iter_at_line_index (out end_iter, line_num, end_match_index);
+ return true;
}
+ // an environment
+ if (end_mark == null)
+ return false;
+
+ _doc.get_iter_at_mark (out line_iter, end_mark);
+ line_num = line_iter.get_line ();
+
+ found = get_low_level_item_bounds (item_type, item_contents, line_num, false,
+ null, out end_match_index);
+
+ if (! found)
+ return false;
+
_doc.get_iter_at_line_index (out end_iter, line_num, end_match_index);
return true;
@@ -765,6 +821,11 @@ public class DocumentStructure : GLib.Object
TextIter begin;
_doc.get_iter_at_line (out begin, line_num);
+ // If the line is empty, and if we do a forward_to_line_end(), we go to the end of
+ // the _next_ line, so we must handle this special case.
+ if (begin.ends_line ())
+ return "";
+
TextIter end = begin;
end.forward_to_line_end ();
diff --git a/src/structure.vala b/src/structure.vala
index ead6d42..968aebc 100644
--- a/src/structure.vala
+++ b/src/structure.vala
@@ -35,6 +35,7 @@ public enum StructType
IMAGE,
TODO,
FIXME,
+ NB_COMMON_TYPES,
// Second part: "high-level" only
TABLE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]