]> git.lyx.org Git - features.git/commitdiff
Restore old bookmark behaviors (stop using bookmark queue)
authorBo Peng <bpeng@lyx.org>
Thu, 29 Mar 2007 03:41:55 +0000 (03:41 +0000)
committerBo Peng <bpeng@lyx.org>
Thu, 29 Mar 2007 03:41:55 +0000 (03:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17628 a592a061-630c-0410-9148-cb99ea01b6c8

lib/bind/aqua.bind
lib/bind/cua.bind
lib/bind/emacs.bind
lib/bind/mac.bind
lib/bind/xemacs.bind
lib/ui/stdmenus.inc
src/BufferView.C
src/BufferView.h
src/session.C
src/session.h

index 893858c9a04793bd8abbff19c20320c524e64d11..609609fc00dc574c54f00cd33f8e48700016a446 100644 (file)
 \bind "M-~S-n e"               "error-next"
 \bind "M-~S-n n"               "note-next"
 \bind "M-~S-n r"               "label-goto"
-\bind "M-~S-n b s"             "bookmark-save 1"
+\bind "M-~S-n S-B 1"   "bookmark-save 1"
+\bind "M-~S-n S-B 2"   "bookmark-save 2"
+\bind "M-~S-n S-B 3"   "bookmark-save 3"
+\bind "M-~S-n S-B 4"   "bookmark-save 4"
+\bind "M-~S-n S-B 5"   "bookmark-save 5"
+\bind "M-~S-n S-B 6"   "bookmark-save 6"
+\bind "M-~S-n S-B 7"   "bookmark-save 7"
+\bind "M-~S-n S-B 8"   "bookmark-save 8"
+\bind "M-~S-n S-B 9"   "bookmark-save 9"
 \bind "M-~S-n b 1"             "bookmark-goto 1"
 \bind "M-~S-n b 2"             "bookmark-goto 2"
 \bind "M-~S-n b 3"             "bookmark-goto 3"
 \bind "M-~S-n b 4"             "bookmark-goto 4"
 \bind "M-~S-n b 5"             "bookmark-goto 5"
+\bind "M-~S-n b 6"             "bookmark-goto 6"
+\bind "M-~S-n b 7"             "bookmark-goto 7"
+\bind "M-~S-n b 8"             "bookmark-goto 8"
+\bind "M-~S-n b 9"             "bookmark-goto 9"
 
 \bind "M-~S-h i"               "help-open Intro"
 \bind "M-~S-h t"               "help-open Tutorial"
index f0abeb0fe2a3e1cb792dc9a002db530d62530283..3db0e1c65aba2d79af158b50e4237e68b4d61a0c 100644 (file)
 \bind "C-~S-3"                 "bookmark-goto 3"
 \bind "C-~S-4"                 "bookmark-goto 4"
 \bind "C-~S-5"                 "bookmark-goto 5"
+\bind "C-~S-6"                 "bookmark-goto 6"
+\bind "C-~S-7"                 "bookmark-goto 7"
+\bind "C-~S-8"                 "bookmark-goto 8"
+\bind "C-~S-9"                 "bookmark-goto 9"
 \bind "C-M-~S-1"               "bookmark-save 1"
+\bind "C-M-~S-2"               "bookmark-save 2"
+\bind "C-M-~S-3"               "bookmark-save 3"
+\bind "C-M-~S-4"               "bookmark-save 4"
+\bind "C-M-~S-5"               "bookmark-save 5"
+\bind "C-M-~S-6"               "bookmark-save 6"
+\bind "C-M-~S-7"               "bookmark-save 7"
+\bind "C-M-~S-8"               "bookmark-save 8"
+\bind "C-M-~S-9"               "bookmark-save 9"
 
 
 #
index da23e8902637c53bc50a9c58b67517b19590d8f7..9b5b233182bb473675645101bdb13634127db248 100644 (file)
 \bind "C-~S-3"                 "bookmark-goto 3"
 \bind "C-~S-4"                 "bookmark-goto 4"
 \bind "C-~S-5"                 "bookmark-goto 5"
+\bind "C-~S-6"                 "bookmark-goto 6"
+\bind "C-~S-7"                 "bookmark-goto 7"
+\bind "C-~S-8"                 "bookmark-goto 8"
+\bind "C-~S-9"                 "bookmark-goto 9"
 \bind "C-M-~S-1"               "bookmark-save 1"
+\bind "C-M-~S-2"               "bookmark-save 2"
+\bind "C-M-~S-3"               "bookmark-save 3"
+\bind "C-M-~S-4"               "bookmark-save 4"
+\bind "C-M-~S-5"               "bookmark-save 5"
+\bind "C-M-~S-6"               "bookmark-save 6"
+\bind "C-M-~S-7"               "bookmark-save 7"
+\bind "C-M-~S-8"               "bookmark-save 8"
+\bind "C-M-~S-9"               "bookmark-save 9"
 
 # The below are xemacs bindings
 #\bind "Home"                   "line-begin"
index e89386a5300bac6b203b78767430abc8542dfc5b..53f5656227aea124638ecb85dc9e91cbb43b99aa 100644 (file)
 \bind "C-~S-3"                 "bookmark-goto 3"
 \bind "C-~S-4"                 "bookmark-goto 4"
 \bind "C-~S-5"                 "bookmark-goto 5"
+\bind "C-~S-6"                 "bookmark-goto 6"
+\bind "C-~S-7"                 "bookmark-goto 7"
+\bind "C-~S-8"                 "bookmark-goto 8"
+\bind "C-~S-9"                 "bookmark-goto 9"
 \bind "C-M-~S-1"               "bookmark-save 1"
+\bind "C-M-~S-2"               "bookmark-save 2"
+\bind "C-M-~S-3"               "bookmark-save 3"
+\bind "C-M-~S-4"               "bookmark-save 4"
+\bind "C-M-~S-5"               "bookmark-save 5"
+\bind "C-M-~S-6"               "bookmark-save 6"
+\bind "C-M-~S-7"               "bookmark-save 7"
+\bind "C-M-~S-8"               "bookmark-save 8"
+\bind "C-M-~S-9"               "bookmark-save 9"
 
 
 #
index 6af4a100829313e4ec7ee47db63dd17057d5d5d9..a759bacc67238cf2325e5642bce12ed33fe2cf38 100644 (file)
 \bind "C-~S-3"                 "bookmark-goto 3"
 \bind "C-~S-4"                 "bookmark-goto 4"
 \bind "C-~S-5"                 "bookmark-goto 5"
+\bind "C-~S-6"                 "bookmark-goto 6"
+\bind "C-~S-7"                 "bookmark-goto 7"
+\bind "C-~S-8"                 "bookmark-goto 8"
+\bind "C-~S-9"                 "bookmark-goto 9"
 \bind "C-M-~S-1"               "bookmark-save 1"
+\bind "C-M-~S-2"               "bookmark-save 2"
+\bind "C-M-~S-3"               "bookmark-save 3"
+\bind "C-M-~S-4"               "bookmark-save 4"
+\bind "C-M-~S-5"               "bookmark-save 5"
+\bind "C-M-~S-6"               "bookmark-save 6"
+\bind "C-M-~S-7"               "bookmark-save 7"
+\bind "C-M-~S-8"               "bookmark-save 8"
+\bind "C-M-~S-9"               "bookmark-save 9"
+
+
 
 #
 # Motion + select group
index f928fb3be7e9db744e087a2858372c585bb33546..39a1c7f7c59d71d21b67e7fb5e851296d3280d5c 100644 (file)
@@ -436,7 +436,11 @@ Menuset
        End
 
        Menu "navigate_bookmarks"
-               Item "Save Bookmark|S" "bookmark-save 1"
+               Item "Save Bookmark 1|S" "bookmark-save 1"
+               Item "Save Bookmark 2" "bookmark-save 2"
+               Item "Save Bookmark 3" "bookmark-save 3"
+               Item "Save Bookmark 4" "bookmark-save 4"
+               Item "Save Bookmark 5" "bookmark-save 5"
                Item "Clear Bookmarks|C" "bookmark-clear"
                Separator
                Bookmarks
index 78e2dc659af7434dff8ec0833f51c53ac8a35129..86ace46c5d6357f6ff3acb9a8846c63ebebacefd 100644 (file)
@@ -551,16 +551,16 @@ Change const BufferView::getCurrentChange() const
 }
 
 
-void BufferView::saveBookmark(bool persistent)
+void BufferView::saveBookmark(unsigned int idx)
 {
        LyX::ref().session().bookmarks().save(
                FileName(buffer_->fileName()),
                cursor_.pit(),
                cursor_.paragraph().id(),
                cursor_.pos(),
-               persistent
+               idx
        );
-       if (persistent)
+       if (idx)
                // emit message signal.
                message(_("Save bookmark"));
 }
@@ -786,7 +786,7 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
                        if (inset) {
                                label = inset->getParam("reference");
                                // persistent=false: use temp_bookmark
-                               saveBookmark(false);
+                               saveBookmark(0);
                        }
                }
 
index 8ebd0e6f94ea40754baa45a027dfb329ec0b4e1d..181b71c14c0d03782d43b5270fb64473a5d81527 100644 (file)
@@ -113,8 +113,8 @@ public:
        ScrollbarParameters const & scrollbarParameters() const;
 
        /// Save the current position as bookmark.
-       /// if persistent=false, save to temp_bookmark
-       void saveBookmark(bool persistent);
+       /// if idx == 0, save to temp_bookmark
+       void saveBookmark(unsigned int idx);
        /// goto a specified position, try par_id first, and then par_pit
        /// return the par_pit and par_id of the new paragraph
        boost::tuple<pit_type, int> moveToPosition(
index e6c6967bc321b01c16ea8d40d69c46c4a92600f1..a43a0c7e83addda0b03350108b498d1e69b8113e 100644 (file)
@@ -231,6 +231,14 @@ LastFilePosSection::FilePos LastFilePosSection::load(FileName const & fname) con
 }
 
 
+void BookmarksSection::clear()
+{
+       // keep bookmark[0], the temporary one
+       bookmarks.resize(1);
+       bookmarks.resize(max_bookmarks + 1);
+}
+
+
 void BookmarksSection::read(istream & is)
 {
        string tmp;
@@ -244,11 +252,14 @@ void BookmarksSection::read(istream & is)
 
                try {
                        // read bookmarks
-                       // pit, pos, file\n
+                       // idx, pit, pos, file\n
+                       unsigned int idx;
                        pit_type pit;
                        pos_type pos;
                        string fname;
                        istringstream itmp(tmp);
+                       itmp >> idx;
+                       itmp.ignore(2);  // ignore ", "
                        itmp >> pit;
                        itmp.ignore(2);  // ignore ", "
                        itmp >> pos;
@@ -260,8 +271,8 @@ void BookmarksSection::read(istream & is)
                        // only load valid bookmarks
                        if (fs::exists(file.toFilesystemEncoding()) &&
                            !fs::is_directory(file.toFilesystemEncoding()) &&
-                           bookmarks.size() < max_bookmarks)
-                               bookmarks.push_back(Bookmark(file, pit, 0, pos));
+                           idx <= max_bookmarks)
+                               bookmarks[idx] = Bookmark(file, pit, 0, pos);
                        else
                                lyxerr[Debug::INIT] << "LyX: Warning: Ignore bookmark of file: " << fname << endl;
                } catch (...) {
@@ -274,41 +285,33 @@ void BookmarksSection::read(istream & is)
 void BookmarksSection::write(ostream & os) const
 {
        os << '\n' << sec_bookmarks << '\n';
-       for (size_t i = 0; i < bookmarks.size(); ++i) {
-               os << bookmarks[i].par_pit << ", "
-                  << bookmarks[i].par_pos << ", "
-                  << bookmarks[i].filename << '\n';
+       for (size_t i = 1; i <= max_bookmarks; ++i) {
+               if (isValid(i))
+                       os << i << ", "
+                          << bookmarks[i].par_pit << ", "
+                          << bookmarks[i].par_pos << ", "
+                          << bookmarks[i].filename << '\n';
        }
 }
 
 
-void BookmarksSection::save(FileName const & fname, pit_type par_pit, int par_id, pos_type par_pos, bool persistent)
+void BookmarksSection::save(FileName const & fname, pit_type par_pit, int par_id, pos_type par_pos, unsigned int idx)
 {
-       if (persistent) {
-               bookmarks.push_back(Bookmark(fname, par_pit, par_id, par_pos));
-               if (bookmarks.size() > max_bookmarks)
-                       bookmarks.pop_back();
-               }
-       else
-               temp_bookmark = Bookmark(fname, par_pit, par_id, par_pos);
+       // silently ignore bookmarks when idx is out of range
+       if (idx <= max_bookmarks)
+               bookmarks[idx] = Bookmark(fname, par_pit, par_id, par_pos);
 }
 
 
 bool BookmarksSection::isValid(unsigned int i) const
 {
-       if (i == 0)
-               return !temp_bookmark.filename.empty();
-       else
-               return i <= bookmarks.size() && !bookmarks[i-1].filename.empty();
+       return i <= max_bookmarks && !bookmarks[i].filename.empty();
 }
 
 
 BookmarksSection::Bookmark const & BookmarksSection::bookmark(unsigned int i) const
 {
-       if (i == 0)
-               return temp_bookmark;
-       else
-               return bookmarks[i-1];
+       return bookmarks[i];
 }
 
 
index 4cf5dcb0808bd0c10c32f43d4bcd0f3f5c347941..3efc9dbdd3548f1678de1e9d50136d777fe19c38 100644 (file)
@@ -199,28 +199,27 @@ public:
        };
 
        ///
-       typedef std::deque<Bookmark> BookmarkList;
+       typedef std::vector<Bookmark> BookmarkList;
 
 public:
        /// constructor, set max_bookmarks
-       /// allow 20 regular bookmarks
-       BookmarksSection() : bookmarks(0), max_bookmarks(20) {}
+       /// allow 9 regular bookmarks, bookmark 0 is temporary
+       BookmarksSection() : bookmarks(10), max_bookmarks(9) {}
 
        /// Save the current position as bookmark
-       /// if save==false, save to temp_bookmark
-       void save(support::FileName const & fname, pit_type pit, int par_id, pos_type par_pos, bool persistent);
+       void save(support::FileName const & fname, pit_type pit, int par_id, pos_type par_pos, unsigned int idx);
 
-       /// return bookmark, return temp_bookmark if i==0
+       /// return bookmark 0-9, bookmark 0 is the temporary bookmark
        Bookmark const & bookmark(unsigned int i) const;
 
        /// does the given bookmark have a saved position ?
        bool isValid(unsigned int i) const;
 
        ///
-       unsigned int size() const { return bookmarks.size(); }
+       unsigned int size() const { return max_bookmarks; }
 
        /// clear all bookmarks
-       void clear() { bookmarks.clear(); }
+       void clear();
 
        ///
        void read(std::istream & is);
@@ -234,10 +233,6 @@ public:
        BookmarkList & load() { return bookmarks; }
 
 private:
-       /// temp bookmark (previously saved_positions[0]), this is really ugly
-       /// c.f. ./frontends/controllers/ControlRef.C
-       /// FIXME: a separate LFUN may be a better solution
-       Bookmark temp_bookmark;
 
        /// a list of bookmarks
        BookmarkList bookmarks;