[gnote] Fix slection deletion and remembering it



commit 24d222bd2ec3f4ec19689e211db3d4e0ac01be91
Author: Aurimas Äernius <aurisc4 gmail com>
Date:   Sun Mar 4 21:38:27 2012 +0200

    Fix slection deletion and remembering it
    
    When some text is selected in note and deleted using delete or backspace
    key with no other modification or cursor movement, after Gnote restart
    the text at the same position is selected (should be cursor in the
    position, where previous selection started).

 src/note.hpp       |    4 ++--
 src/notebuffer.cpp |    6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/note.hpp b/src/note.hpp
index e0569a3..f69a36a 100644
--- a/src/note.hpp
+++ b/src/note.hpp
@@ -56,6 +56,8 @@ class NoteData
 {
 public:
   typedef std::map<std::string, Tag::Ptr> TagMap;
+  static const int s_noPosition;
+
   NoteData(const std::string & _uri);
 
   const std::string & uri() const
@@ -186,8 +188,6 @@ private:
   bool              m_open_on_startup;
 
   TagMap m_tags;
- 
-  static const int  s_noPosition;
 };
 
 
diff --git a/src/notebuffer.cpp b/src/notebuffer.cpp
index df223f3..b1b6e97 100644
--- a/src/notebuffer.cpp
+++ b/src/notebuffer.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2010-2011 Aurimas Cernius
+ * Copyright (C) 2010-2012 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -541,6 +541,8 @@ namespace gnote {
     if (selection) {
       augment_selection(start, end_iter);
       erase(start, end_iter);
+      m_note.data().set_cursor_position(get_insert()->get_iter().get_offset());
+      m_note.data().set_selection_bound_position(NoteData::s_noPosition);
       return true;
     } 
     else if (start.ends_line() && start.get_line() < get_line_count()) {
@@ -590,6 +592,8 @@ namespace gnote {
     if (selection) {
       augment_selection(start, end_iter);
       erase(start, end_iter);
+      m_note.data().set_cursor_position(get_insert()->get_iter().get_offset());
+      m_note.data().set_selection_bound_position(NoteData::s_noPosition);
       return true;
     } 
     else {



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