mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
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
This commit is contained in:
parent
ce899a9fa1
commit
6fc7d47a5f
@ -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"
|
||||
|
@ -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"
|
||||
|
||||
|
||||
#
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
||||
|
||||
#
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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 << ", "
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user