From: Bo Peng Date: Thu, 29 Mar 2007 03:41:55 +0000 (+0000) Subject: Restore old bookmark behaviors (stop using bookmark queue) X-Git-Tag: 1.6.10~10430 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=6fc7d47a5f88276f0aff75e90cd5230613b872e9;p=features.git Restore old bookmark behaviors (stop using bookmark queue) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17628 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/bind/aqua.bind b/lib/bind/aqua.bind index 893858c9a0..609609fc00 100644 --- a/lib/bind/aqua.bind +++ b/lib/bind/aqua.bind @@ -132,12 +132,24 @@ \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" diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index f0abeb0fe2..3db0e1c65a 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -168,7 +168,19 @@ \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" # diff --git a/lib/bind/emacs.bind b/lib/bind/emacs.bind index da23e89026..9b5b233182 100644 --- a/lib/bind/emacs.bind +++ b/lib/bind/emacs.bind @@ -157,7 +157,19 @@ \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" diff --git a/lib/bind/mac.bind b/lib/bind/mac.bind index e89386a530..53f5656227 100644 --- a/lib/bind/mac.bind +++ b/lib/bind/mac.bind @@ -156,7 +156,19 @@ \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" # diff --git a/lib/bind/xemacs.bind b/lib/bind/xemacs.bind index 6af4a10082..a759bacc67 100644 --- a/lib/bind/xemacs.bind +++ b/lib/bind/xemacs.bind @@ -172,7 +172,21 @@ \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 diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index f928fb3be7..39a1c7f7c5 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -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 diff --git a/src/BufferView.C b/src/BufferView.C index 78e2dc659a..86ace46c5d 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -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); } } diff --git a/src/BufferView.h b/src/BufferView.h index 8ebd0e6f94..181b71c14c 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -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 moveToPosition( diff --git a/src/session.C b/src/session.C index e6c6967bc3..a43a0c7e83 100644 --- a/src/session.C +++ b/src/session.C @@ -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]; } diff --git a/src/session.h b/src/session.h index 4cf5dcb080..3efc9dbdd3 100644 --- a/src/session.h +++ b/src/session.h @@ -199,28 +199,27 @@ public: }; /// - typedef std::deque BookmarkList; + typedef std::vector 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;