[gnote] Add select_note_body to NoteBuffer



commit b7d32bff1fc17fab397a2d3a75318b34e0421db4
Author: Aurimas Ä?ernius <aurisc4 gmail com>
Date:   Sun Feb 27 19:01:07 2011 +0200

    Add select_note_body to NoteBuffer
    
    A method to select note body, excluding title and all whitespace
    between title and first non-whitespace character.
    Intended to be used for selecting note body when creating new note.
    Fixes Bug 627072.

 src/notebuffer.cpp |    9 +++++++++
 src/notebuffer.hpp |    1 +
 2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/src/notebuffer.cpp b/src/notebuffer.cpp
index 2f1a013..120f3e6 100644
--- a/src/notebuffer.cpp
+++ b/src/notebuffer.cpp
@@ -1105,6 +1105,15 @@ namespace gnote {
     return depth_tag;
   }
 
+  void NoteBuffer::select_note_body()
+  {
+    Glib::ustring title = m_note.get_title();
+    Gtk::TextIter iter = get_iter_at_offset(title.length());
+    while(isspace(*iter))
+      iter.forward_char();
+    move_mark(get_selection_bound(), iter);
+    move_mark(get_insert(), end());
+  }
 
   std::string NoteBufferArchiver::serialize(const Glib::RefPtr<Gtk::TextBuffer> & buffer)
   {
diff --git a/src/notebuffer.hpp b/src/notebuffer.hpp
index ae39d1d..b2e9c23 100644
--- a/src/notebuffer.hpp
+++ b/src/notebuffer.hpp
@@ -109,6 +109,7 @@ public:
   void decrease_depth(Gtk::TextIter & start);
   DepthNoteTag::Ptr find_depth_tag(Gtk::TextIter &);
   static bool is_bullet(gunichar c);
+  void select_note_body();
 protected: 
   NoteBuffer(const NoteTagTable::Ptr &, Note &);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]